Reply
Visitor
Posts: 2
Registered: ‎05-29-2017

How to edit utag.link

Suppose I have the following (existing) code in the header of a page:

 

utag.link ({
"order_total": 1000.0,
"order_tax": 150
};)

For convenience, I want to insert a new calculated variable, so it becomes:

 

utag.link ({
"order_total": 1000.0,
"order_tax": 150.0,
"order_subtotal": 850.0 //difference };)

This change should be made accessible to all tags.

Trouble is, I do not have the right to edit the source code and must do it in Tealium iQ. What is the way to achieve it?

 

 

Reply
0 Kudos
Highlighted
Occasional Contributor
Posts: 18
Registered: ‎03-02-2017

Re: How to edit utag.link

Hey @LongPun,

You can use a Set Data Values (or a JavaScript) extension where you substract order_tax from order_total whenever both are defined, and scope it to All Tags. 

Something like this should work:

if(b.order_total && b.order_tax) {
  b.order_subtotal = parseFloat(b.order_total) - parseFloat(b.order_tax);
  b.order_subtotal = b.order_subtotal.toFixed(2).toString();
}

Just double check the format is correct (dot or comma).

Visitor
Posts: 2
Registered: ‎05-29-2017

Re: How to edit utag.link

Thanks @psanchez.

Trouble is, the data are hard-coded in a utag.link() call, and the variables inside (e.g. order_total) is not directly accessible with the b variable. So when I tried your code, since either b.order_total nor b.order_tax exist in b, it does not work for the case.

Any other suggestions?

Reply
0 Kudos
Occasional Contributor
Posts: 126
Registered: ‎12-11-2015

Re: How to edit utag.link

Hi @LongPun 

The variable within an All Tags extension running either Before Load Rules or After Load Rules will contain the event payload that was passed into the utag.link call, the solution above will definitely work. I think it's worth debugging your code using the information here to check what's happening.

Community Manager
Posts: 360
Registered: ‎09-01-2015

Re: How to edit utag.link

@LongPun It might be worth noting that the code you posted has syntax errors. The semicolon after the object is invalid. Are you sure it's executing correctly?

utag-link-error.png

The UTAG Monitor is another tool to help you diagnose event tracking issues: Universal Tag (UTAG) Debugger

 

Remember to "Accept as Solution" when your question has been answered and to give kudos to helpful replies.