I have a custom GTM tag template in which I try to use the getCookieValues API by specifying the cookie name.
I can see that the cookie exists on the website and has a value. But when I run the template code, getCookieValues always gives me empty value. I have the appropriate permission set for reading ‘any cookies’.
Can someone please help?
This is the template code snippet for getting the cookie value:
const cookieName = ‘test_cookie’;
const consentStr = queryPermission(‘get_cookies’, cookieName) ? getCookieValues(cookieName, true)[0] : undefined;
log(‘consentstr=’+consentStr);
user24677074 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.