Acquia's default Varnish VCL strips Google Analytics query string parameters

Acquia implemented a minor platform enhancement in 2017.  After conducting a performance audit, we concluded that many requests were being cached as unique items in Varnish.  These requests fit a particular profile: each utilized URL parameters (or "query strings") to manage application behavior or to analyze traffic, trends, activities, or referrals.

These parameters can be useful, but they create a high number of URL variations, each uniquely stored in Varnish.  Our research showed that these variations were mostly expendable, as they needlessly consumed memory.  Stripping these parameters instead of storing them in Varnish improves the cache hit rate considerably for applications that experience traffic spikes based on successful marketing campaigns.

Example: Google Analytics

For most customers, stripping these parameters from Varnish does not introduce a problem.  For example, the Google Analytics module provides JavaScript code that loads on every page.  The incoming request passes the relevant parameters to the JavaScript before stripping them and caching the page in Varnish.  Stripping the parameters from the cached rendered page is inconsequential, in most cases.

Do you use PHP to capture these parameters?  

If you use PHP code to capture the parameters, the recommended best practice is to use JavaScript to process those parameters.  For example, the following JavaScript could be used to save the values as variables that can be passed on to a PHP application:

// Credits go to
function get_url_parameter(param_split) {
    var page_url =;
    var parameters = page_url.split('&');
    for (var i = 0; i < parameters.length; i++) {
        var param = parameters[i].split('=');
        if (param[0] == param_split) {
            return param[1];

// Remove or uncomment the parameters that you don't need.
params = [];
params['gclid'] = get_url_parameter('gclid');
params['dclid'] = get_url_parameter('dclid');
params['cx'] = get_url_parameter('cx');
params['ie'] = get_url_parameter('ie');
params['cof'] = get_url_parameter('cof');
params['siteurl'] = get_url_parameter('siteurl');
params['fclsrc'] = get_url_parameter('fclsrc');
params['zanpid'] = get_url_parameter('zanpid');
params['os_ehash'] = get_url_parameter('os_ehash');
params['origin'] = get_url_parameter('origin');
params['hConversionEventId'] = get_url_parameter('hConversionEventId');
params['utm_source'] = get_url_parameter('utm_source');
params['utm_campaign'] = get_url_parameter('utm_campaign');
params['utm_content'] = get_url_parameter('utm_content');
params['utm_medium'] = get_url_parameter('utm_medium');
params['utm_term'] = get_url_parameter('utm_term');

// Send the data to a special path on the Drupal-side.
   type: "POST",
   data: {params:params},
   url: "/special/callback/that/gathers/parameters",
   success: function(msg){

Do you need some additional help understanding this?

These things can be tricky!  On rare occasions, a custom VCL may be the solution.  We can help you determine if this is your best course of action.  If you have any questions, please contact Acquia Support by logging into and visiting the Acquia Help Center.  We have a full Support staff ready to help you navigate this issue, and many more.

Review Date

Contact supportStill need assistance? Contact Acquia Support