I have return below JavaScript function to read cookie name and value. I am able to fetch name and value when I use the script in Chrome and Firefox browser console.
getCookie('xyz') ;
function getCookie(name)
{
var re = new RegExp(name + "=([^;]+)");
var value = re.exec(document.cookie);
return (value != null) ? unescape(value[1]) : null;
}
but when I use same code in Google Tag Manager by using Custom JavaScript variable I am getting error "parenthesis ( required".
I am not able to figure out what is error as this code is running everywhere except in Google Tag Manager.