> For the complete documentation index, see [llms.txt](https://docs.exads.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.exads.com/advertisers/campaigns/conversion-tracking/conversion-tracking-gtm.md).

# Setting Up Google Tag Manager

Google Tag Manager is a [tag management system (TMS)](https://en.wikipedia.org/wiki/Tag_management_system). It lets you update [tags](https://www.google.com/tagmanager/answer/3281060) on a website or mobile app. Tags are tracking codes and related code fragments.

After adding Tag Manager code, deploy analytics and measurement tags from its web interface.

After [installing](https://www.google.com/tagmanager/answer/6103696) Tag Manager, use its web interface to:

* Set up tracking tags.
* Establish [triggers](https://www.google.com/tagmanager/answer/6106961) that fire tags during specific events.
* Create [variables](https://www.google.com/tagmanager/answer/6106899) that simplify tag configurations.

A collection of tags, triggers, variables, and related configurations installed on a given website or mobile app is called a container. A Tag Manager container can replace all other manually-coded tags on a site or app, including tags from [Google Ads](https://support.google.com/tagmanager/topic/6334091), [Google Analytics](https://support.google.com/tagmanager/topic/6333310), and [EXADS Pixel Tracking](/advertisers/campaigns/conversion-tracking/setting-up-conversion-tracking.md#step-7-using-pixel-tracking).

## 1. Account Creation <a href="#id-1-account-creation" id="id-1-account-creation"></a>

**1.1.** Access [Google Tag Manager](http://tagmanager.google.com/) and [create a new account](https://support.google.com/tagmanager/answer/6103696?hl=en).

**1.2.** After creating the account, Google Tag Manager displays its script. Add this code to your landing page. It will not work until you configure a **Tag** and **Trigger**.

![banner](https://docs-advanced.exads.com/docs/assets/hires/gtm-3.png)

## 2. Setting up the Variable <a href="#id-2-setting-up-the-variable" id="id-2-setting-up-the-variable"></a>

Create a variable to pass `{conversions_tracking}` from the campaign URL to the postback URL. TO create a variable, click **Variables**, then **User-Defined Variables** and **New**:

![Variable](https://docs-advanced.exads.com/docs/assets/hires/gtm-variable1.jpg)

Pass this value through the **URL** or a **1st Party Cookie**.  If you can pass the {conversion\_string} string to the URL where the conversion happens, then we recommend using **URL**. Otherwise, we suggest using **1st Party Cookie**.

### 2.a: URL Variable <a href="#id-2a-url-variable" id="id-2a-url-variable"></a>

**2.a.1.** - The URL Variable method is the easiest and quickest method for integration. Click on “Variable Configuration” and select “URL”:

![URL Variable](https://docs-advanced.exads.com/docs/assets/hires/gtm-variable2.jpg)

**2.a.2.** - Select "Query" as Component Type and add "tag" in the Query Key:

![Query](https://docs-advanced.exads.com/docs/assets/hires/gtm-variable3.jpg)

**2.a.3.** - Save the Variable.

### 2.b: 1st Party Cookie <a href="#id-2b-1st-party-cookie" id="id-2b-1st-party-cookie"></a>

**2.b.1.** - This setup allows you to have access to additional Triggers and set ups, but in order to use it you will have to fetch the **{conversions\_tracking}** string from the Campaign URL and store it in a **Cookie**.

You will have to place the following code in the URL that contains the {conversions\_tracking} string:

```
<script>
function createCookie(){
var url_string = window.location.href
var url = new URL(url_string);
var tag = url.searchParams.get("tag");
document.cookie = "tracking="+tag;
}
</script>
```

**2.b.2.** - Click on “Variable Configuration” and select “1st Party Cookie”:

![1st Party Cookie](https://docs-advanced.exads.com/docs/assets/hires/gtm-variable4.png)

**2.b.3.** - In “Cookie Name”, add “tracking”:

![Cookie Name](https://docs-advanced.exads.com/docs/assets/hires/gtm-variable5.png)

**2.b.4.** - Save the Variable.

## 3. Setting up the Trigger <a href="#id-3-setting-up-the-trigger" id="id-3-setting-up-the-trigger"></a>

The trigger determines when Google Tag Manager fires the tag. This guide covers **Page View** and **Link Click** [triggers](https://support.google.com/tagmanager/topic/7679108). **Link Click** requires the **1st Party Cookie** variable.

Click "New" on the "Triggers" page and then select "Page View" in the Trigger Type list:

![Trigger Type](https://docs-advanced.exads.com/docs/assets/hires/gtm-trigger1.jpg)

### 3.a. Page View <a href="#id-3a-page-view" id="id-3a-page-view"></a>

**3.a.1.** - Select “Page View” as trigger type:

![Page View](https://docs-advanced.exads.com/docs/assets/hires/gtm-pageview1.jpg)

**3.a.2.** - "Some Page Views" and, in "Page URL", add the Domain that should fire this tag:

![Page View](https://docs-advanced.exads.com/docs/assets/hires/gtm-pageview2.jpg)

While you do not have to specify the full URL, make sure that this URL is the same as the one that contains the **{conversions\_tracking}** string.

**3.a.3.** - Save the trigger.

### 3.b. Link Click <a href="#id-3b-link-click" id="id-3b-link-click"></a>

**3.b.1.** - Select “Just Links” as trigger type:

![Link Click](https://docs-advanced.exads.com/docs/assets/hires/gtm-linkclick1.jpg)

**3.b.2.** - In the trigger settings, select “Some Link Clicks”, then determine the condition in which the click would fire the pixel.

For instance, if the tag will be fired once the user clicks on a “Complete registration” link, then you should put the URL of the “registry complete” page as a Page URL condition:

![Link Click](https://docs-advanced.exads.com/docs/assets/hires/gtm-linkclick2.jpg)

For a purchase, use `purchase_complete` when the thank-you page URL contains it:

![Trigger Condition](https://docs-advanced.exads.com/docs/assets/hires/gtm-linkclick3.jpg)

{% hint style="info" %}
As an additional filter to make sure all postbacks you sent are valid, you can enable “Check Validation” and add a condition where the {conversions\_tracking} variable must not be empty, as shown below:

<img src="https://docs-advanced.exads.com/docs/assets/hires/gtm-linkclick4.jpg" alt="Check Validation" data-size="original">
{% endhint %}

**3.b.3.** - Save the trigger.

## 4. Setting up the Tag <a href="#id-4-setting-up-the-tag" id="id-4-setting-up-the-tag"></a>

The tag calls the postback URL. To create the tag, click **New** in **Tags** and select **Custom Image** as the tag type:

![New Tag](https://docs-advanced.exads.com/docs/assets/hires/gtm-tag1.jpg)

Then, in "Image URL", add the following URL:

```
https://syndication.example.com/tag.php?goal=GOAL_ID&tag=
```

{% hint style="info" %}
syndication.example.com to be substituted with the conversion domain used by your ad server.
{% endhint %}

Make sure to disable Cache Busting and substitute the GOAL\_ID value with the Goal ID from the advertiser's account.

Then, click on the button next to the Image URL:

![Tag Configuration](https://docs-advanced.exads.com/docs/assets/hires/gtm-tag2.jpeg)

Select the Variable you created in step 2.

![Variable](https://docs-advanced.exads.com/docs/assets/hires/gtm-tag3.jpg)

Now your Image URL should look like this:

```
https://syndication.example.com/tag.php?goal=707d6f1e95027111340084c5ea4c25e9&tag={{Postback query}}
```

Lastly, select the Trigger you created in step 3:

![Trigger](https://docs-advanced.exads.com/docs/assets/hires/gtm-tag4.jpg)

## 5. Submit and publish Google Tag Manager configuration <a href="#id-5-submit-and-publish-google-tag-manager-configuration" id="id-5-submit-and-publish-google-tag-manager-configuration"></a>

Submit and publish the configuration.

![Publish](https://docs-advanced.exads.com/docs/assets/hires/gtm-publish1.jpg)

Now, the request to the Postback URL should be seen in the website. When this Postback URL is requested, a conversion should be registered in the campaign:

![Campaign](https://docs-advanced.exads.com/docs/assets/hires/gtm-publish2.jpg)

![Campaign](https://docs-advanced.exads.com/docs/assets/hires/gtm-publish3.png)

![Campaign](https://docs-advanced.exads.com/docs/assets/hires/gtm-publish3.jpg)

## Important notes on this guide <a href="#important-notes-on-this-guide" id="important-notes-on-this-guide"></a>

{% hint style="info" %}

* With Postback URL tracking, the Admin user must add the "conversions\_tracking" tag in the campaign URL. The information provided by the "conversions\_tracking" tag **must reach the website where the Google Tag script** is located, otherwise the variable won't pick up the information from the tag. This is why we advise to use "Page View" as trigger instead of using other triggers: while it is possible to send the string from "conversions\_tracking" through other means, it is much easier and more reliable to get it from the campaign URL.
* This integration will generate a 1x1 blank image on the website. Since it is an image tag, it will be affected by any CSS rules the client might have on the website, so make sure that this image does not get any styling. Otherwise, a broken/blank image might be displayed on the site.
* Currently there is no way to track conversions with Adblock enabled because Adblock blocks Google's GTM script.
  {% endhint %}

## Troubleshooting <a href="#troubleshooting" id="troubleshooting"></a>

### **Conversions not being fired**

Occasionally, pixels do not get fired, even when the script has been added on the site:

![banner](https://docs-advanced.exads.com/docs/assets/hires/gtm-18.png)

This usually happens because Google strips out the ID from the Goal, preventing it from associating the user with a specific account goal. In order to solve this issue, you will have to add the following script in the "Tag Configuration" section from Google Tag Manager (Step 2.2 above):

```
<script>
(function() {
var el = document.createElement('script');
el.setAttribute('src', 'https://XXX_EXAMPLE_XXX/tag_gen.js'); // to be replaced with correct url
el.setAttribute('data-goal', 'XXX_GOAL_ID_XXX'); // to be replaced with correct goal id value
document.body.appendChild(el);
})();
</script>
```

![banner](https://docs-advanced.exads.com/docs/assets/hires/gtm-19.png)

Make sure to replace 'XXX\_GOAL\_ID\_XXX' with the ID from the Goal you want to use.

<br>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.exads.com/advertisers/campaigns/conversion-tracking/conversion-tracking-gtm.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
