ePrivacy and GPDR Cookie Consent by Cookie Consent Skip to main content

How to implement a cookie with timestamp on GTM

Insert the following script to Google Tag Manager:


var createCookie = function(cookieName, value) {
document.cookie = cookieName + "=" + encodeURI(value) + ";domain=chemistwarehouse.com.au;path=/;secure;samesite=strict";
}

createCookie("meiro_product_added_timestamp", new Date().toISOString());



The first part of the script states a function that can be called whenever there is a need to create a cookie. You will need to input a cookie name and its value. 

Use case for abandonned basket web banner

In this case the cookie meiro_product_added_timestamp will be created when a product is added or changed  e.g. in the shopping cart and a trigger has to be defined in Google Tag Manager. To learn more about this use case, please reach out to the Meiro team.

Learn more about abandonned basker web banner HTML template.