GTM Tag Manager: 1st Party Cookie
Budget: $10 – $30 USD
We use GTM's datalayer to set a userId cookie (using a 1st party cookie variable in GTM). Everything works perfectly when I test in GTM preview mode, but for some reason it's not setting the cookie value when I open a browser window outside of GTM's preview mode?
This is the Java snippet where I used the datalayer to set the userId variable (I can confirm that this method is fired by checking the Developer Console log in Google Chrome)
function setUserId(data) {
console.log('setUserId fired');
window.dataLayer = window.dataLayer || [];
window.dataLayer.push({
'userId': data
})
}
Here's a URL to test the Cookie setup: https://member.roadsave.co.za/chat?chatbotid=H-631091-NKYDGLV61ZU70CLB (you have to click the "Set GA UserID & Cookie with Basic Script" button > enter the new userId and then click Send > reload page to view cookie value (or check Developer Console n Google Chrome)
I've also taken screenshots of the Cookie setup in GTM itself.
I think I'm missing something small as it works in GTM preview mode, but not outside of GTM preview mode.
This is the Java snippet where I used the datalayer to set the userId variable (I can confirm that this method is fired by checking the Developer Console log in Google Chrome)
function setUserId(data) {
console.log('setUserId fired');
window.dataLayer = window.dataLayer || [];
window.dataLayer.push({
'userId': data
})
}
Here's a URL to test the Cookie setup: https://member.roadsave.co.za/chat?chatbotid=H-631091-NKYDGLV61ZU70CLB (you have to click the "Set GA UserID & Cookie with Basic Script" button > enter the new userId and then click Send > reload page to view cookie value (or check Developer Console n Google Chrome)
I've also taken screenshots of the Cookie setup in GTM itself.
I think I'm missing something small as it works in GTM preview mode, but not outside of GTM preview mode.