How do you reference a cookie value in templates?

Gold Contributor
Gold Contributor

When I try to reference a value in the utag_main cookie object in templates using "b["cp.utag_main_nameofcookievalue"]" 

(from this article: Link), I get a reference error. What would be the correct syntax for this?

2 REPLIES 2

How do you reference a cookie value in templates?

Employee Emeritus

Hi @landin_gee,

You shouldn't be getting this reference error.  When modifing a tag template, you'll want to make sure you're referencing the 'b' object inside of the u.send function.  This function will have access to the 'b' object and as such, you'll be able to reference your cookie.  In addition, make sure you're referencing the exact value of the cookie name as seen in the utag.data object.  Some of the utag_main cookies have two underscores in them such as "cp.utag_main__sn".  

 

If you're still having issues, it would be helpful if you can include the code you're trying so we can help to diagnose it.  

 

Thanks

How do you reference a cookie value in templates?

Gold Contributor
Gold Contributor

Thanks for the quick reply @jason_paddock. That works, thanks!

Public