Google Tag Manager

How Google Tag Manager can help with installing Attribution

Google Tag Manager (GTM) is a tool for injecting snippets of code onto a website based on rules that you set in the GTM app.

The basic concept for the Attribution app integration is that we want to inject the main attribution snippet on every page, one time, right when that page is loaded. You can inject page() to run analytics.js via Google tag manager.

**However, you cannot install Attribution.identify() OR Attribution.track() with Google Tag Manager**


1. Inject the Attribution app snippet on every page

The first thing we want to do is inject the main attribution app snippet on every page, one time, right when that page is loaded. To do this we will click to create a new tag, and select "Custom HTML Tag". Then, paste the code from your Attribution settings.


You will want to make sure that the code is triggered on all pages.


Tag Firing Priority

This tag has to be fired before any other Attribution app tags. In order to do this, you'll need to assign it a "Tag firing priority" of greater than 0. Tags with higher numbers for priority will be fired first.


Robot Proofing

GTM uses a noscript IFrame to allow for scriptless tracking. However, this is generally only used by bots. In order to ignore these bot events, and keep your data clean, we advise wrapping all Attribution app code snippets in an if statement:

<script type="text/javascript">
  if ('gtm-msr.appspot') == -1) {
    /* Attribution code here */

Although, this is not shown in the screenshots, it should be added to all tags.

A note on using GTM

It is technically possible to instal track() and identify() using Google tag manager, but it is a very complex process. When calling identify() or track() Attribution will look for a userId or anonymous cookieId, in most cases Google Tag Manager will not pass the anonymous cookieId which prevents tying events to visitors in Attribution.