Highlighted

Reference Tag Number in Tag Scoped JS Ext

Rookie Contributor

Is there a way to retreive the tag number in a tag scoped javascript extension? I want to do something like this:

if(utag number == 87){ do something }

I realize I could put this code in a tag scoped extension scoped only to that tag but its part of a large extension that needs to run for a bunch of tags except for this one line. 

2 REPLIES 2
Highlighted

Reference Tag Number in Tag Scoped JS Ext

Tealium Expert
Tealium Expert
Hi @seth_poplaski - I'm pretty sure this is possible, but I don't have a code sample ready. You might browse your utag.js for some ideas, looking for occurrences of the tag id you are interested in. That might give you some ideas how to adapt your own solution. Also Tealium support can help you with some ideas too, if you open a ticket at Support Desk (bottom left of nav menu)
Highlighted

Reference Tag Number in Tag Scoped JS Ext

Gold Contributor
Gold Contributor

Hi @seth_poplaski ,

  You can leverage the 'u' object from the tag for getting the id.

All tags are async self-executing tag with the below structure,

(function(id, loader) { 

    var u = {

    'id' : id

  } 

....

 

}( 'our tag id' , 'account.profile' ));

The tag scoped extension will be inside the tag while loading, in a function object called u.extend

 

To use the id in tag scoped extension, you can try like below

if ( u.id == 'your tag id' ) {

Then exectue the code

}

 

I just tried to print 'true' in my console when my 'Tag Id' is met and I am able to see the result in console.

Adding id.png

 

Thanks,

VJ

 

Its Not Who I am Underneath, but What I Do That Defines Me