After initializing the Tag Manager script, you have to instruct Cookie Saver which cookies to save. When doing so, you have a number of configuration values.
This guide explains how to add cookies as part of the configuration of the Tag Manager. This is done after the initialization of the script and before starting the service.
Basic
In most cases the following will be sufficient to add a cookie:
acq("addCookie", {
"name": INSERT COOKIE NAME,
"expirationDays": INSERT VALUE
});
Where:
- "name" (string), mandatory, is the name of the cookie that should be saved
- "expirationDays" (integer), mandatory, is the wanted expiration of the cookie in number of days
Note: If you have cookies that lie directly on your domain without a leading dot, you will need to look at the advanced setup. This is often the case for Cookie Contents / Cookie Disclaimers.
Advanced
If you need a more advanced setup due to some special cookies that you have on your website, Cookie Saver offers the following configuration options for each cookie:
acq("addCookie", {
"name": INSERT COOKIE NAME,
"expirationDays": INSERT VALUE,
"safariOnly": INSERT VALUE,
"domain": INSERT DOMAIN,
"autoExtend": INSERT VALUE,
"backup": INSERT VALUE,
"secure": INSERT VALUE
});
Where:
- "name" (string), mandatory, is the name of the cookie that should be saved
- "expirationDays" (integer), mandatory, is the wanted expiration of the cookie in number of days
- "safariOnly" (boolean), optional, is whether this cookie should be saved in all browsers or only in Safari (this flag overwrites the safariOnly flag set during initialization, if set). Default is True.
- "domain" (string), optional, is any specific domain that the cookie should be set in, if not the top-level domain. Default is the top-level domain specified during initialization.
- "autoExtend" (boolean), optional, is whether this cookie should have its expiration extended every time the user visits your website. Default is True.
- "backup" (boolean), optional, is whether Cookie Saver should create and use a backup cookie with a "_acs_" prefix. Default is True.
- "secure" (boolean), optional, is whether Cookie Saver should restore the original cookie as a secure cookie.
Example:
acq("addCookie", {
"name": "_ga",
"expirationDays": 730,
"safariOnly": false,
"backup": false
});
The above will extend the Google Analytics cookie "_ga" to two years (730 days) every time the user visits the website in all browsers. No backup cookie will be used, thus it is important that GA is configured to not automatically overwrite the "_ga" cookie with each tracking request.
Read more: Google Analytics
When to use the Advanced?
Case 1:
If you have a Cookie Consent cookie that is set directly in your domain without a leading dot, e.g. for https://cookiesaver.io we have a Cookie Consent cookies that is placed in "cookiesaver.io" (notice no leading dot), you will need to specify the domain when adding the cookie.
Example:
acq("addCookie", {
"name": "cookie-consent",
"expirationDays": 365,
"domain": "cookiesaver.io"
});
Case 2: You are running with an affiliate setup where your affiliates are paid by a 30-day lookback window based on an affiliate cookie. It is important that this cookie is not auto-extended as you don´t want to extend the lookback window for commission payment.
Example:
acq("addCookie", {
"name": "affiliate-cookie",
"expirationDays": 30,
"autoExtend": false
});
Comments
0 comments
Please sign in to leave a comment.