- TLC Home Home
- Discussions Discussions
- Documentation Documentation
- Knowledge Base Knowledge Base
- Education Education
- Blog Blog
- Support Desk Support Desk
10-14-2020 08:14 AM
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.
Solved! Go to Solution.
10-14-2020 01:41 PM
10-16-2020 04:37 AM
Hi @spoplaski1 ,
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.
Thanks,
VJ
Copyright All Rights Reserved © 2008-2023