- TLC Home Home
- Discussions Discussions
- Documentation Documentation
- Knowledge Base Knowledge Base
- Education Education
- Blog Blog
- Support Desk Support Desk
01-12-2021 07:55 AM
I'm working on vue.js based SPA, and sometimes I need to manipulate the DOM on specific pages (views).
If I write a js in an extension, that runs only once. I want to run them every time the user goes to another page of my site without overwriteing the whole utag.view function. (In that case I would lose other setups)
Thank you,
Sam
01-13-2021 04:54 AM
Hi @tUser_1842 ,
Yes, extensions can be executed for every call, when you set the scope properly.
If the scope of your extension is in preloader or DOM-ready then the extension will be executed once, because the preloader and dom-ready event will fire when the utag.js library is loaded (Page load).
So to execute the extension for every call (utag.view / utag.link), you can scope the extension to before load rules /after load rules / tag scoped extensions/ after tags.
If you are using Javascript code extension then there is an option called occurrence, where you can select 'Run Always' to execute the extension on (utag.view / link call). In your case for utag.view, set the condition to fire only on view.
Please refer the below link,
Extension : https://community.tealiumiq.com/t5/iQ-Tag-Management/Extensions/ta-p/13649
Order of Operations : https://community.tealiumiq.com/t5/iQ-Tag-Management/Order-of-Operations/ta-p/326
Thanks,
VJ
01-13-2021 05:27 AM - edited 01-13-2021 05:44 AM
Hi VJ,
Thank you for your advices.
1. I've changed the scope to "Tag scoped extension" and choose a Tag that seems to run on every page re-render (and only once). So it seems to be working now, thank you so much.
2. I also tried to use "After load rules" and "After tag extensions" scope, and set run always but in this case the extension runs several times indeed. I don't find an option to reduce it to utag.view only.
However 1 is working so I'm gonna go with it.
Thanks for your help again,
Sam
01-13-2021 06:03 AM - edited 01-13-2021 06:04 AM
Changing occurence to "Run only once" works well!
Thanks!!
10-03-2022 01:18 PM
Copyright All Rights Reserved © 2008-2023