After initializing the Tag Manager script, you have to instruct Cookie Saver which cookies to save. One of the most common cookies is the Google Analytics one.
This guide explains which are Google Analytics cookies and how they should be added to your configuration. The following applies to both Google Analytics and Google Analytics 360.
It is assumed that Universal Analytics is used. For more information about the cookies that are used by Google Analytics, please see: https://developers.google.com/analytics/devguides/collection/analyticsjs/cookie-usage
Google Analytics sets a number of different cookies used to keep track of unique users and throttle tracking requests. In order to preserve the known users, you only need to focus on the "_ga" cookie, which is set to an expiration of 2 years per default (capped to 7 days in Safari due to ITP).
The GA library automatically overwrites and extends the "_ga" cookie with every tracking request. As a consequence, every time the "_ga" cookie is overwritten by GA, the expiration is set to 7 days. To avoid this, we have two ways of persisting the "_ga" cookie using Cookie Saver.
Method 1: Using a backup cookie
Important: This method requires the Preload script to be in place. See Preload script
Per default, Cookie Saver will create and use a backup cookie named "_acs__ga" and always keep this one up-to-date. Whenever a page loads, the Preload script will make sure that the "_ga" cookie is available for Google Analytics. If the "_ga" has been deleted due to e.g. ITP, the Preload script will re-create it before Google Analytics is requesting it.
Configuration to be included in your Cookie Saver installation:
acq("addCookie", {
"name": "_ga",
"expirationDays": 730
});
Method 2: Without a backup cookie
Important: This method requires you to update your Google Analytics implementation.
By setting "backup" to false you force Cookie Saver to not create and use any additional cookie. Additionally, you will need to set the "safariOnly" flag to false as the changes to your Google Analytics setup will require that Cookie Saver update the "_ga" cookie for all browsers.
As no backup cookie is created, it is important that GA does not overwrite the "_ga" cookie at any time. This ensures that Cookie Saver will always succeed in having the "last" touch on the cookie, making sure that the expiration is set correctly and not impacted by e.g. ITP.
Configuration to be included in your Cookie Saver installation:
acq("addCookie", {
"name": "_ga",
"expirationDays": 730,
"backup": false,
"safariOnly: false
});
If Google Analytics is deployed through GTM, we recommend one of the following two approached to your GA setup:
Update using a Google Analytics Settings variable
If you are using a Google Analytics Settings variable for your setup, updating GA to not automatically overwrite the "_ga" cookie is simple.
Within the Google Analytics Settings variable, select "More Settings" and "Fields to Set". Type in "cookieUpdate" and set the value to false.
Make sure that Cookie Saver is live and publish your changes.
Update all your Google Analytics tags
Important: It is critical that all GA tags are updated. Even a single tag not updated can result in the "_ga" cookie not being extended correctly.
For each of your GA tags, check the "Enable overriding settings in this tag". Select "More Settings" and "Fields to Set". Type in "cookieUpdate" and set the value to false.
Make sure that Cookie Saver is live and publish your changes once you have updated all the GA tags.
Comments
0 comments
Please sign in to leave a comment.