I want to add a tag but I want to implement its java script directly

Gold Contributor
Gold Contributor

I want to tadd the tag to my site. But i don't want to add it with the usual Tealium generic tag container and then specify the image pixel. Rather i want to add the whole java script.

 

How can i do it?

 

Example Script is like this - 

 

<script type="text/javascript">
(function () {
var a = document,
b = a.createElement("script"),
a = a.getElementsByTagName("script")[0];
b.type = "text/javascript";
b.async = !0;
b.src="http://tag.com/partnerCode/tag.js";
a.parentNode.insertBefore(b, a)
})();
</script>

also through this implementation is it possible to first have it for some pages and then later for the whole site? from the load rule point of view ?

2 REPLIES 2

I want to add a tag but I want to implement its java script directly

Tealium Employee

Hi @shailesh_gaikwa,

 

For your example script you can add it into a JavaScript extension. Just paste all of the code except the <script> & </script> tags. Here is an example using your code of how that would look:

 

 

imageext.png

 

As far as load rules, you can create a lookup table and set a data source parameter based on the criteria you wish to load the library. Or it may be easier to exclude the pages you do not want the library to load. In the JavaScript extension, you could test for the value which signals to load the library. Here's just an example that might help you along. I've created it to always fire except if landing on a certain set of pages, based on pathname:

 

 

imageLookupTable.png

 

Updating the JavaScript extension would then be needed to apply the load rule. Using the data source set in the lookup table, the JavaScript extension would then look something like:

 

updatedExtension.png

 

For loading the library for all pages on a future date, you would remove the if check in the extension and disable the lookup table. Basically your JavaScript extension would look like the first image above. If you wanted to do this programmatically, such as firing on all pages after a certain date, you could add that to the if check in the JavaScript extension, as an OR condition, that satisfies the point in time you wish the library to load on all pages.

 

 

I want to add a tag but I want to implement its java script directly

Gold Contributor
Gold Contributor

Hi David,

 

Thanks for your response.

 

Our requirement changed hence did not need this approach however it was good to know this way of implementation and I am sure it will help me in the future :)

Public