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.

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:

<script type="text/javascript" src="//"></script>
<script type="text/javascript">
var tsid =23360;, false, "");

Then 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. Now, any time the GTM is loaded, it will call that JavaScript that you’ve added once you click “Publish.”  

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