How can I take the value of a cookie set by one tag and use it as a data source for another tag?

luke_schlegel
Not applicable
luke_schlegel
I'm trying to link my A/B testing utility (Optimizely) to my call tracking utility (Mongoose Metrics). Optimizely creates a cookie optimizelyBuckets that contains the experiment and variation identification numbers in the following format:{"Experiment_Id":"Variation_Id"} I want to use these numbers as part of my Mongoose Metrics code, specifically as the custom variable so that I can track phone calls back to the experiment and variation. I can see the cookie in web companion, but am not sure how to make it usable by other tags.
3 REPLIES 3

How can I take the value of a cookie set by one tag and use it as a data source for another tag?

son_hoang
Employee Emeritus
son_hoang
Hi Luke, You'd add it as a data source to your data sources tab. The name would be "optimizelyBuckets" and the data source would be "cookie value", you can find out more here: https://community.tealiumiq.com/posts/541657/ That's the basic step, but since it looks like it stores it in a JSON format, you probably don't want just a string that looks like {"Experiment_Id":"Variation_Id"}, although since it is a string you could technically map it as a data point to any tag at this point or use it for a condition for tag loading or extension firing. If you want to split the values, you'd need to write some custom JavaScript in a JavaScript extension to parse out the experiment ID from the variation ID. It really depends on your needs. If you do need help writing this code, please contact your account manager.

How can I take the value of a cookie set by one tag and use it as a data source for another tag?

Tealium Employee
Just to add to this - what Son has suggested will work perfectly after the page has loaded once, but on the initial page load if Optimizely has not yet created its cookie, Tealium can't pick the cookie value up. All subsequent page loads will, however, receive the cookie value. I don't know if the initial pageload is important to you, but it would be a good idea to keep this in mind.
Check out our new Swift integration library for iOS, macOS, tvOS and watchOS: https://github.com/Tealium/tealium-swift with updated
documentation https://community.tealiumiq.com/t5/Swift/tkb-p/swift.
Highlighted

How can I take the value of a cookie set by one tag and use it as a data source for another tag?

Tealium Employee
Note that Mongoose Metrics has been rebranded and is now DialogTech East Rules Engine.