Skip to content

Varnish VCL: does not exclude Google Campaign URLS #10087

@iancassidyweb

Description

@iancassidyweb

Description

Merchants will often use acquisition campaigns to drive traffic to their website and wish to record this information in Google Analytics.

Whilst the standard Varnish 4 VCL file produced by Magento contains exclusion rules for the 'gclid' parameter often seen in paid ad campaigns; it does not contain any exclusion for campaign urls.

This subsequently means that when a user renders a page and includes one of the standard campaign parameters Varnish will miss its cache and create a new version of the cached page.

The cache will also be missed for all variations of campaign url structures leading to an increased varnish cache size and a massively inefficient caching process.

Google have a standard campaign url structure and the builder which can be visited below:
https://ga-dev-tools.appspot.com/campaign-url-builder/

Preconditions

  1. Magento 2 CE or EE Version 2.1.7
  2. Varnish 4 installed

Steps to reproduce

  1. Install either Magento 2 EE or CE version 2.1.7
  2. Export the default Varnish 4 VCL from the admin panel
  3. Apply Varnish VCL
  4. Load the Magento homepage and ensure the X-Magento-Cache-Debug:HIT headers are present
  5. Load the same page again by applying a random campaign url i.e utm_source=test
  6. You will see the page is not cached by varnish
  7. If you load the page again you will see the page has now been cached in varnish
  8. Create a variation of the utm_source parameter i.e. utm_source=test2
  9. When inspecting the varnish headers you will see the page has not being returned from Varnish by inspecting the X-Magento-Cache-Debug:MISS headers.

Expected result

  1. As Magento comes with Google Analytics and AdWords integration the standard VCL file should contain additional exclusion rules for Google's standard campaign URL structure.

Actual result

  1. Varnish will create a new copy of the page in its cache for each variant of the campaign url structure.

For Example:

Version 1 = www.mywebsite.com
Version 2 = www.mywebsite.com?utm_source=Facebook
Version 3 = www.mywebsite.com?utm_source=Facebook&utm_medium=Remarketing
Version 4 = www.mywebsite.com?utm_source=Facebook&utm_medium=Remarketing&utm_campaign=Summer2017

Metadata

Metadata

Assignees

No one assigned

    Labels

    Component: Framework/CacheFixed in 2.3.xThe issue has been fixed in 2.3 release lineIssue: Clear DescriptionGate 2 Passed. Manual verification of the issue description passedIssue: ConfirmedGate 3 Passed. Manual verification of the issue completed. Issue is confirmedIssue: Format is validGate 1 Passed. Automatic verification of issue format passedIssue: Ready for WorkGate 4. Acknowledged. Issue is added to backlog and ready for developmentReproduced on 2.1.xThe issue has been reproduced on latest 2.1 releaseReproduced on 2.2.xThe issue has been reproduced on latest 2.2 releasebug report

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions