Question

I have no experience with Varnish, so please bear with me.

We have inserted Google Tag Manager into a clients site. The Tag Manager injects Google Analytics tracking code (and nothing else) into the page. The clients technical service provider has now complained that the Tag Manager prevents the Varnish cache from working.

My guess is that this has nothing to do with the tag manager as such but is rather caused by the cookies from Google Analytics - apparently in the default configuration pages with cookies are not cached. However since I'm not very familiar with Varnish I cannot speak with any authority in the matter.

So my question is: is there any reason why Google Tag Manager itself (not any tags inside the tag manager) would invalidate a Varnish cache on each request ? A web search turned up nothing specific regarding Varnish and GTM.

Thank you for your time,

Eike

Was it helpful?

Solution

Google Tag Manager will not interfere with Varnish cache in any way. The reason being is that the requests for Google Tag Manager are sent to google-analytics.com, not your website.

The cookies are then set by google-analytics.com and are only sent between the clients browser and google-analytics.com.

This means that Google Tag Manager does not actually have any affect on your website apart from the initial Javascript being loaded from there.

OTHER TIPS

In fact varnish does not validate any cookie that is created through javascript, only caches the "set-cookie header" of the http request.

The problem you may be having is, if the "DataLayer" is placed in the html code, the values of the variables do not change as they would be in cache. To solve this problem, we must make another http call (ex. ajax) does not to cache, it returns the variables for DataLayer.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top