Highlighted

How do I test backward compatibility for utag.js v4.40?

Silver Contributor
Silver Contributor

In the Release notes

https://community.tealiumiq.com/t5/uTag/utag-js-version-4-40-and-4-41-Release-Notes/ta-p/12946

 

there is this paragraph: 

"Previously, items in current data layer passed to utag.link/view were merged into the utag.data global object. This was required to re-evaluate load rules for each utag.link/view call. The utag.js 4.40 template takes advantage of a publish engine update so that this is no longer required. In version 4.40, the utag.data global object will not be updated with each utag.link or utag.view call."

 

Then there is this:

 

"IMPORTANT: You may use the following JS Extension to test for backwards compatibility with v4.39 behavior before updating to v4.40. 

// JS Extension scoped to "Before Load Rules"
utag.ut.merge( b, utag.data, 0 );
utag.ut.merge( utag.data, b ,1 );

 "

I added this code. How will it help me in veriyfing whether I can update or not?

 

 

4 REPLIES 4
Highlighted

How do I test backward compatibility for utag.js v4.40?

Silver Contributor
Silver Contributor

(How can I edit my question?)

 

Also here a question to make sure I understand the consequences of such an update:

 

Right now:

1. page loads and fills utag.data with myvar = "hund" - >utag.data['myvar'] = "hund". Tags to fire when myvar = "hund" fire.

 

2. On the same page, utag.link({"myvar":"katze"}) fires. -> utag.data['myvar'] = "katze" . Tags fire if they are configured to fire when myvar = "katze". Tags that are configured to fire when myvar = "hund" won't fire

 

3. Another utag.link call fires and sets the previously undefined "hisvar" to "maus". utag.data['hisvar'] = "maus". Tags fire if they are configured to fire when hisvar = "maus" OR when myvar = "katze"

 

 

After v4.40:

 

1. same

2. utag.data['myvar'] remains "hund". Tage to fire when myvar = "katze" won't fire. Tags to fire when myvar = "hund" fire again.

3. Same as 2.

Highlighted

How do I test backward compatibility for utag.js v4.40?

Tealium Employee

Hi @loldenburg

 

Let me start of by clarifying what is happening.

 

In utag v4.39 and below data all data was merged onto the main utag.data object due to the need by the load rules.

 

v4.40 and above, this is no longer the case. utag.data, will be from the inital page view call / or an explicit additions you might have done.

 

What the code snippet does, is allow utag v.4.40+ to act like it previously did. So all data sent on a utag.view/link or track call will be merged into the utag.data object.

 

You only need to add this is you want to keep that same functionality.

 

 

utag v4.39 and below the data would look like:

utag v4.40 and above the data would look like:

//Inital page view

var utag_data = {   myvar : 'hund' }

// This will create the
//utag.data object of

utag.data =>
{
//dom properties
//cp properties
//qp properties
//meta properties
//....
myvar : 'hund'
}
//Inital page view

var utag_data = {   myvar : 'hund' }

// This will create the
//utag.data object of

utag.data =>
{
//dom properties
//cp properties
//qp properties
//meta properties
//....
myvar : 'hund'
}

Now if a view/link or track call happens:

utag.link({myvar : 'katze'});

// This will update the
// utag.data object to look like

utag.data =>
{
//dom properties
//cp properties
//qp properties
//meta properties
//....
myvar : 'katze'
}

//Passed in object data - after merge

{
//dom properties
//cp properties
//qp properties
//meta properties
//....
myvar : 'katze'
}

Now if a view/link or track call happens:

utag.link({myvar : 'katze'});

// This will update the
// utag.data object to look like

utag.data =>
{
//dom properties
//cp properties
//qp properties
//meta properties
//....
myvar : 'hund'
}

//Passed in object data

{
//dom properties
//cp properties
//qp properties
//meta properties
//....
myvar : 'katze'
}

 Now if another event happens:

utag.link({hisvar : 'maus'});

// This will update the 
// utag.data object to look like utag.data =>
{ //dom properties //cp properties //qp properties //meta properties //.... myvar : 'katze',
hisvar : 'maus' }

//Passed in object data - after merge

{
//dom properties
//cp properties
//qp properties
//meta properties
//....
hisvar : 'maus'
}

 Now if another event happens:

utag.link({hisvar : 'maus'});

// This will update the 
// utag.data object to look like utag.data =>
{ //dom properties //cp properties //qp properties //meta properties //.... myvar : 'hund' }

//Passed in object data

{
//dom properties
//cp properties
//qp properties
//meta properties
//....
hisvar : 'maus'
}

 

 Hopefully this helps explain everything.

 

Adrian

Ask me anything Tealium related or Javascript, or NodeJS.
Please remember to mark solutions as accepted for future searchers.
Highlighted

How do I test backward compatibility for utag.js v4.40?

Silver Contributor
Silver Contributor
Amazing, thanks. You should link to this post in the documentation.

"Passed in object data" means the data that is used for Rule Checking and Mapping.
So a rule to fire a tag on hisvar = "maus" would still fire after v40, right?
Highlighted

How do I test backward compatibility for utag.js v4.40?

Tealium Employee

 

"Passed in Object data" is the data that was sent through on the utag.view/link call.

 

A rule with hisvar = "maus" will fire indeed still fire with or with out the extra lines of code.

 

Now if you still wanted to fire the rule myvar = 'katze' on the link request in version 4.40, you would need to add the merge lines from above to the first All Tags Scoped Extension.

 

Adrian

Ask me anything Tealium related or Javascript, or NodeJS.
Please remember to mark solutions as accepted for future searchers.