- TLC Home Home
- Discussions Discussions
- Documentation Documentation
- Knowledge Base Knowledge Base
- Education Education
- Blog Blog
- Support Desk Support Desk
Is it possible to delay a script to load on the second page that a user visits instead of the first? Any examples I can use for reference?
Thanks in advance,
Paul
09-22-2017 11:46 AM - last edited on 09-22-2017 01:22 PM by kathleen_jo
@paul_leech, there are some Tealium built-in first party cookies you could use to accomplish this. To use these data layer elements in the UI, click on the "Add Variable" dropdown on the right side of the Data Layer screen and choose "Add Common Variables". On the left hand side of the resulting popup choose "Tealium Built-in Data" and import this bundle.
The cookie you'd want to use for only firing a tag on a certain page view count is utag_main__pn, which persists a page view count. You could create a load rule with the logic of "utag_main__pn is equal to 2". Attach this load rule to your tag, and the tag would only fire on the second page view.
If you want a tag to fire on a page view other than the first, you could use utag_main__ss, which is a flag for start of session. On the first page view this value would be 1, otherwise 0.
09-22-2017 04:40 PM
@dave_milsom Thanks for the quick response, Dave! I came up with this Load Rule based on your post. I haven't tried it yet because the other piece I need to figure out is how to convert a script and two JavaScript include files into something that I can load into a tag.
Would you happen to know how can I convert the following into pure JavaScript?
<script type="text/javascript">
(function() {
try {
var viz = document.createElement("script");
viz.type = "text/javascript";
viz.async = true;
viz.src=("https:" == document.location.protocol ?"https://cdn6.vizury.com" : "http://cdn6.vizury.com")+ "/analyze/pixel.php?account_id=VIZVRM6547";
var s = document.getElementsByTagName("script")[0];
s.parentNode.insertBefore(viz, s);
viz.onload = function() {
try {
pixel.parse();
} catch (i) {
}
};
viz.onreadystatechange = function() {
if (viz.readyState == "complete" || viz.readyState == "loaded") {
try {
pixel.parse();
} catch (i) {
}
}
};
} catch (i) {
}
})();
</script>
<script type="text/javascript" src="//cdn25.vizury.com/ssp/US_NorthShoreCare/vizury_data.json"></script>
<script type="text/javascript" src="//cdn25.vizury.com/ssp/US_NorthShoreCare/wpn5195.js"> </script>
The part that I'm not sure about is how to get the last two include files without the script tags.
09-25-2017 09:57 AM - edited 09-25-2017 09:57 AM
@paul_leech You could add the main script as a Generic Tag, with the following as the base URL:
//cdn6.vizury.com/analyze/pixel.php?account_id=VIZVRM6547
Taking advantage of Tealium's script loader function from the tag template, create a JavaScript code extension, scope it to the tag, and add this as the code:
u.loader({ type: "script", src: "//cdn25.vizury.com/ssp/US_NorthShoreCare/vizury_data.json" }); u.loader({ type: "script", src: "//cdn25.vizury.com/ssp/US_NorthShoreCare/wpn5195.js" });
Copyright All Rights Reserved © 2008-2023