All Collections
Using Genius Link with other services
Adding Custom JavaScript to Your Website Using Google Tag Manager
Adding Custom JavaScript to Your Website Using Google Tag Manager

How to add a customized JavaScript snippet to a GTM tag, so you can easily apply it to numerous websites

Joey White avatar
Written by Joey White
Updated over a week ago

How to add Custom JavaScript Code to a GTM Tag

1. Head over to Google Tag Manager and log in to your account. Once you’re in, select New Tag.

2. On the next page, label the new tag if you wish, and select Custom HTML Tag.

3. Paste in the code of your choosing - or in this case, the Geniuslink JavaScript Snippet, which you can generate here.

NOTE: As of February 23rd, 2017 the following changes must be made to the JS snippet for it to operate properly with GTM.

You will need to remove the "document.addEventListener("DOMContentLoaded", function() {" line from the JavaScript Snippet, so your new JS Snippet should look like this:

var tsid =23360;, false, "");

Once you've pasted (and edited) the snippet, select any advanced settings, like the tag firing options.

  • Once per event means every time the GTM code is fired, this will also fire.

  • Once per page will only fire once, even if GTM is fired multiple times.

4. Click on Triggering and select DOM Ready as the Trigger.

For our snippet, we recommend having it fire every time GTM is fired, so that you ensure your links are always globalized and affiliated.

Select which events you’d like the tag to fire with — all DOM Ready Events or only some DOM Ready events.

5. Click Publish. Now, any time the GTM is loaded, it will call that JavaScript that you’ve added.

GTM also allows you to preview the changes before pushing live, so you can test to make sure everything is working!

Did this answer your question?