- TLC Home Home
- Discussions Discussions
- Documentation Documentation
- Knowledge Base Knowledge Base
- Education Education
- Blog Blog
- Support Desk Support Desk
06-22-2016 01:00 PM
Hello,
How do I take data enriched data layer sources (i.e. badges from Audience Stream) and write a pipe delimited list of the badge IDs to a 1st party cookie?
I found the article on visitor service cookie callbacks here:
But want to make sure I'm understanding correctly. Also, I'd like to have the call back happen on every pageload/server call (any issues with that from a technical or billing perspective?)
Are below steps correct:
1. add badge(s) as enriched data layer object.
2. use code below in a pre-loader javascript call:
window.tealium_enrichment = function(data) {
console.log("Visitor Service Cookie Callback");
var page = utag.data.page_name;
var dest = data['properties']['BadgeID1'] || "" data['properties']['BadgeID2'] || ""
if (dest !== "") {
utag.loader.SC("myCookieName", dest);
}
};
Then publish and test.
?
Solved! Go to Solution.
06-22-2016 01:13 PM
Do you want to set all badges/audiences, or just a select few badges/audiences? Let me know and we'll guide on the best script to use.
Doing the callback on every event is not an issue, meaning it will not effect your billing. The only extra "cost" is the loading and running (very little in the grand scheme of things) of the script.
Also, that callback should be scoped to the Tealium Collect tag.
Cheers,
-Dan
06-22-2016 01:44 PM
What up @dan_george! Thx for response.. seems like you're the local forum crawler?
I'm not sure if i'll be doing all badges/audiences - might depend on how many we end up with. Can you share both options (selected badge/audiences and all badges/audiences) with brief pros/cons?
06-22-2016 01:48 PM - edited 06-22-2016 01:54 PM
This will add all badges to a cookie.
window.tealium_enrichment = function(data) { //console.log("Visitor Service Cookie Callback"); var badges=""; for(i in utag.data){ if(i.indexOf("va.badges")==0){ //console.log(i+" = "+utag.data[i]); badges+=i.replace("va.badges.","")+"|"; } } if(badges!=""){ utag.loader.SC("myCookieName", badges); } };
The end results will be cookie "myCookieName" with a value of "5082|5101|5203|5465|".
Adding audiences to this code is very simple.
The pro of doing this is it doesn't have to be maintained/updated each time a new badge/audience is added. It will just automatically add your new badge ID and audience name.
The con of doing this is that if you have a lot of badges and audiences then the cookie could potentially get rather large.
The example above can easily be edited to look for specific badge/audience IDs if need be.
06-22-2016 02:38 PM
08-10-2016 07:41 AM
@dan_george Hey Dan! What if I want to set the values to a varaible in Local Storage instead of cookies?
08-10-2016 07:50 AM
Then you can change:
utag.loader.SC("myCookieName", badges);
To be the logic to save to localStorage.
The basic structure of what you need is stated above, and you can edit as you see fit.
08-10-2016 07:51 AM
And now I see the silliness of my question. Thanks:)
08-10-2016 08:04 AM
05-31-2018 12:47 AM
Hi Dan,
I am trying to do the same thing - write the badge names onto a cookie. I have saved the exact code here in an extension and variously scoped it to All tags, Pre Loader and Tealium Collect tags but the logs do not appear at all. Can you suggest any possible reason?
Thanks a lot,
Regards,
Sujani
06-01-2018 07:54 AM
@sujani_koya the only thing I can think of is that within the Tealium Collect tag you have Data Enrichment set to "none". Change this to "frequent" and that will allow the AudienceStream attributes to be pulled back into the web page.
Second, please be sure to update to the latest version of the Collect tag. If you're unfamiliar with doing so I'd suggest following these directions.
I hope this helps!
06-01-2018 02:14 PM
Thanks Dan! Both these steps helped. Seeing the logs now :)
06-04-2018 08:48 AM
OOOOooooo.... I'd accept @dan_george's reply as a solution @sujani_koya! #JustSaying
#hugs
06-04-2018 08:55 AM
Unfortunately I am not the original poster so can't accept as the solution!
06-04-2018 08:57 AM
Thank you for trying @sujani_koya! #EvenMoreHugs!!!
Copyright All Rights Reserved © 2008-2023