Is there a way to set an expiry date on tracking tags that run on your website, specifically when using google tag manager?
Is there a way to set an expiry date on tracking tags that run on your website, specifically when using google tag manager?
There isn't a built in way to do this, but you can set it up without too much trouble. First set up a new User-Defined Variable, use the type "Custom Javascript" , and call it something helpful like "Date". Put the following script in as the value:
function () {
var d = new Date();
var y = d.getFullYear();
var m = (d.getMonth() + 1 + '').padStart(2,0);
var d = (d.getDate() + '').padStart(2,0);
return y + m + d;
}
That will give you a variable which returns the date in a format like YYYYMMDD. So, for example, on February 14, 2007, it would return 20070214.
Save that variable, and in the trigger that fires your tag, set a condition like [name of your variable] less than [desired date of expiration]. Along the lines of :
Date less than 20200603
With that, the tag will only fire if the date is before June 3, 2020.
You can use this same technique to only fire tags _after _ a certain date as well.
In Google Tag Manager you can set a firing schedule for a tag under "Advanced Settings".
The limitation here is that you cannot use variables for dates (if you feel that actually somehow limits here).