utag.link leverage JS variables vs UDO variables

Silver Contributor
Silver Contributor

I have an analytics specific JSON object that I have mapped tealium to so inside of tealium these are all JS variables.  If I want to leverage utag.link () to push event-based data into our analytics tools.  This is problematic because any variable passed within utag.link() is set up as a UDO variable.  This creates to variables with identical values.  e.g. js_product_name and simply product_name which makes mappings a nightmare.  Any recommendations on how to solve?

1 REPLY 1

utag.link leverage JS variables vs UDO variables

Tealium Expert
Tealium Expert

If all you want to do is take the contents of your analytics object and push it into the UDO with each event, @JoeBrown, then you could achieve that with the following JavaScript extension, set to run before load rules (ideally as one of the first things you run):

window.utag.ut.merge(b,your_analytics_object,0);


This will copy all variables from your_analytics_object into the event payload, without overwriting any that are already set.

So in this case, if your analytics object contains a "product_name" variable, that will be added into the event payload unless a variable with that name already exists (flip the third argument "0" to a "1" if you want to overwrite by default). Then you need only have a single instance of each variable in your UDO definition which should make mapping easier. This assumes that the variables in your analytics object already have the same names as the target UDO elements to which you want them mapped..

Public