> ## Documentation Index
> Fetch the complete documentation index at: https://docs.zeotap.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Implement the Google Tag Manager Source

Google Tag Manager (GTM) is a useful tool that allows you to manage and deploy marketing tags, snippets of code or tracking pixels on your website or mobile app without having to modify the code. With the GTM integrated, you have multiple tags stored in one place and therefore it becomes handy for the Marketer to manage all the codes on their own.

There are three main parts to GTM:

* **Tags** – Snippets of JavaScript or tracking pixels
* **Triggers** – This tells GTM when or how to fire a tag
* **Variables** – Additional information GTM may need for the tag and trigger to work

## Before you Begin

Ensure that you have created your GTM account and installed the GTM container to use the Zeotap Collect Tag Template. For more information about Tags, Account and Containers, and how to set them up in Google Tag Manager, refer to [Setting up and Installing Tag Manager.](https://support.google.com/tagmanager/answer/6103696?hl=en).

## Overview of Zeotap Collect Tag Template

The Zeotap Collect Tag is available as a custom template on Google Tag Manager (GTM) for easy integration. This is a JavaScript (JS) tag that is used to capture events and user information as customers navigate your websites. It is asynchronous and does not affect the loading of the site or the end-user experience.

The Zeotap Collect tag requires a data layer to be set up on your websites. This data layer would be used for capturing event information. The data layer ensures that all the relevant information for segment activation or event orchestration is available. The data layer object is flattened and used in the corresponding collection calls.
GTM's custom templates allow you to write your own tag and variable definitions so that others within your organization can use them alongside the built-in tag and variable templates. These custom templates allow you to build a user interface around the custom code you might want to run on your website using GTM. This user interface comprises text input fields, settings, tables, labels, drop-down menus and so forth.

## Steps to Configure Zeotap Collect Tag in GTM

Perform the following steps to configure the Zeotap Collect Tag in Google Tag Manager (GTM):

1. [Add/Import the Zeotap Collect Tag Template](#step-1-add/import-the-zeotap-collect-tag-template)

2. [Add the Tag](#step-2-add-the-tag)

3. [Configure the Tag](#step-3-configure-the-tag)

   a. [Initialisation Options](#initialisation-options)

   b. [Tracking page views and events](#tracking-page-views-and-events)

   c. [Login and Identities Setting](#login-and-identities-settings)

   d. [Google Analytics Configuration](#google-analytics-configuration)

   e. [Advanced Settings](#advanced-settings)

4. [Set up the Trigger](#step-4-set-up-the-trigger)

5. [Validate the Configured Collect Tag](#step-5-validate-the-configured-collect-tag)

## Step 1 - Add/Import the Zeotap Collect Tag Template

You can add the Zeotap Collect Tag Template in one of the following ways:

### Method 1

Perform the following steps to add the Zeotap Collect Tag Template in GTM as mentioned in Method 1:

<Steps>
  <Step>
    Log into your GTM account and click **Templates** from the left menu.
  </Step>

  <Step>
    Under **Tag Templates**, click the **Search Gallery** on the top-right corner.

    <Frame>
      <img src="https://mintcdn.com/zeotap/puXmsvA7x0OblYvo/articles/integrate-customer/Storage/integrate-customer/project-collect-internal/CD/attachments/2665775403/2693628838.png?fit=max&auto=format&n=puXmsvA7x0OblYvo&q=85&s=df6b1c89ed23c0019a3f6e5900735f41" width="3584" height="1868" data-path="articles/integrate-customer/Storage/integrate-customer/project-collect-internal/CD/attachments/2665775403/2693628838.png" />
    </Frame>
  </Step>

  <Step>
    Search and choose **Zeotap Collect Tag** **Template** from the list.
  </Step>

  <Step>
    Click **Add to your workspace** to add the Tag Template for further usage.
  </Step>
</Steps>

### Method 2

Perform the following steps to add the Zeotap Collect Tag Template as mentioned in Method 2:

<Steps>
  <Step>
    Check with your Zeotap Product Operations Manager for the template file. It is shared as a `.tpl ` file.
  </Step>

  <Step>
    Log into your GTM account and click **Templates** from the left menu.
  </Step>

  <Step>
    Under **Tag Templates**, click **New** on the top-right corner.
  </Step>

  <Step>
    In the top-right corner, click the vertical ellipses and select **Import**.

    <Frame>
      <img src="https://mintcdn.com/zeotap/puXmsvA7x0OblYvo/articles/integrate-customer/Storage/integrate-customer/project-collect-internal/CD/attachments/2665775403/2693334087.png?fit=max&auto=format&n=puXmsvA7x0OblYvo&q=85&s=6b5461484bde71edb0d0e20ca4c8293f" width="3584" height="1886" data-path="articles/integrate-customer/Storage/integrate-customer/project-collect-internal/CD/attachments/2665775403/2693334087.png" />
    </Frame>
  </Step>

  <Step>
    Select the `.tpl` file shared in step 1 above.
  </Step>

  <Step>
    Name the template as **Zeotap Collect Tag** and save it for further usage.
  </Step>
</Steps>

## Step 2 - Add the Tag

Once you have added the Tag Template, the next step is to add the tag. Perform the following steps to add the Tag:

<Steps>
  <Step>
    Log into your GTM account and click **Tags** from the left menu.
  </Step>

  <Step>
    Click **New** and name the tag descriptively. For example, **Zeotap Collect.**
  </Step>

  <Step>
    Click **Tag Configuration** and search for **Zeotap Collect Tag Template**. The Tag is listed under the **Custom** tab.
  </Step>

  <Step>
    Click **Zeotap Collect Tag Template**. To configure the tag, follow the steps mentioned under **Configure the Tag.**

    <Frame>
      <img src="https://mintcdn.com/zeotap/puXmsvA7x0OblYvo/articles/integrate-customer/Storage/integrate-customer/project-collect-internal/CD/attachments/2665775403/2693628858.png?fit=max&auto=format&n=puXmsvA7x0OblYvo&q=85&s=f09db348a12953ab88c7c730e9c08763" width="3568" height="1450" data-path="articles/integrate-customer/Storage/integrate-customer/project-collect-internal/CD/attachments/2665775403/2693628858.png" />
    </Frame>
  </Step>
</Steps>

## Step 3 - Configure the Tag

The process of configuring a Tag is divided into the following sections:

* Initialisation Options
* Tracking page views and events
* Login and identities setting
* Google Analytics Configurations
* Advanced Settings

<Frame>
  <img src="https://mintcdn.com/zeotap/puXmsvA7x0OblYvo/articles/integrate-customer/Storage/integrate-customer/project-collect-internal/CD/attachments/2665775403/2693628869.png?fit=max&auto=format&n=puXmsvA7x0OblYvo&q=85&s=f5e70b9723c7f6461cbadb8eeeb054de" width="3584" height="1238" data-path="articles/integrate-customer/Storage/integrate-customer/project-collect-internal/CD/attachments/2665775403/2693628869.png" />
</Frame>

### Initialisation Options

Enter the following details to configure the initialisation options:

* **Write Key** - When you create a GTM-based source in your Zeotap CDP account, a write key is provided in the source details. This is a mandatory field for recording events.
* **User Country** - This is the [ISO Alpha 3 country code](https://www.iban.com/country-codes) that is used to determine the region for storage. If this country code is not sent, then the Zeotap servers use the IP Address to determine the same. Therefore, use this country code if your account is set up only for specific regions.
* **Event Key** - This the key against which event names are stored in the `dataLayer` object. You can choose not to fill this if you are using the GTM's default key - event.
* **Data Persistence** - In case of multi-domain websites, the identifiers are reset once the user navigates to a webpage with a different domain name. In such scenarios, you can click the **Persist data in cookie storage** check box, which continues to store their identifiers in the *Cookie storage,* irrespective of the domain name of the web page they browse through.
* **Consent Method**\* -The Collect SDK has three options that can be used to determine consent actions. **.**

  a. **Default Opt-in** - This option sets the `optOut` option to `false` and is used to record events. Choose this option to fire the tag only for the consented users. The consent communication happens through other methods such as API integration, file upload and so on. You can also use the options available under Additional Consent Settings to send TC string and custom brand consent.

  <Frame>
    <img src="https://mintcdn.com/zeotap/99ae7Xt83Dkoy1LQ/articles/integrate-customer/Storage/integrate-customer/implementing-google-tag-manager-source-2665775403/implementing-google-tag-manager-source-2665775403-2025-02-20.png?fit=max&auto=format&n=99ae7Xt83Dkoy1LQ&q=85&s=cbe04dde33f42e99129b4eae2058a54e" width="732" height="610" data-path="articles/integrate-customer/Storage/integrate-customer/implementing-google-tag-manager-source-2665775403/implementing-google-tag-manager-source-2665775403-2025-02-20.png" />
  </Frame>

  b. **Check TCF CMP**– This option sets the `useConsent` and `checkForCMP` options to `true`. The JS automatically checks for the presence of the `cmp.js` script and the `__cmp` variable in the global scope. The JS also queries the `TCF API` to fetch the latest Publisher consent before recording the events on each JS load.

  Ensure that you configure the parameter Purposes for tracking of events, while using the GDPR consent module. This option is used to pass a list of purpose IDs, based on which you can manage the consent for tracking. By default, the three options shown in the image below are selected. However, you can modify them based on your requirement. You can also use the option available under Additional Consent Settings to send custom brand consent.

  <Frame>
    <img src="https://mintcdn.com/zeotap/99ae7Xt83Dkoy1LQ/articles/integrate-customer/Storage/integrate-customer/implementing-google-tag-manager-source-2665775403/implementing-google-tag-manager-source-2665775403-2025-02-20-1.png?fit=max&auto=format&n=99ae7Xt83Dkoy1LQ&q=85&s=0500c5c9cb330ec082f54a01cb5f278e" width="1600" height="1740" data-path="articles/integrate-customer/Storage/integrate-customer/implementing-google-tag-manager-source-2665775403/implementing-google-tag-manager-source-2665775403-2025-02-20-1.png" />
  </Frame>

  c. **Custom Consent** – To configure custom consent, select **Custom Consent** as the consent method under the **Initialization Options**. Then, specify the following details in the SDK Consent Signals section:

  <Note>
    **NOTE**:

    You can also use the option available under Additional Consent Settings to send TC string and custom brand consent.
  </Note>

  * Event name: Choose the `dataLayer` event that is fired when custom consent is set.
  * Other Variables: Choose the `dataLayer` variables for setting the values of **Track**, **Identify** and **Cookie Sync** signals.

  <Frame>
    <img src="https://mintcdn.com/zeotap/99ae7Xt83Dkoy1LQ/articles/integrate-customer/Storage/integrate-customer/implementing-google-tag-manager-source-2665775403/implementing-google-tag-manager-source-2665775403-2025-02-20-2.png?fit=max&auto=format&n=99ae7Xt83Dkoy1LQ&q=85&s=7ec30c17eb0fda85ea701234e37a49f7" width="1538" height="1660" data-path="articles/integrate-customer/Storage/integrate-customer/implementing-google-tag-manager-source-2665775403/implementing-google-tag-manager-source-2665775403-2025-02-20-2.png" />
  </Frame>

### Tracking Page Views and Events

Enter the following details to configure the tracking options:

* **Page View Tracking Event Name**\*–\* By default, we track page view for the `gtm.js` event name. When using some other event name, ensure to update that event name in the input for overriding.
* **Event Tracking** – Enter a regex pattern that matches all the event names you want to track. If you want to track just a single event, then just enter that event name. By default, we use the `.*` pattern to identify the events.
* **Special Events** – If you want to track event names apart from the regex provided, then add all such events here.
* **Pre Defined Properties** – Input the properties that you want to attach or override. You can either define the values from your variables or provide static values for them.
* **PII to be excluded** – Enter all the PII and user-related fields in the dataLayer that need to be from in the event properties. For example, email is pushed into the dataLayer in the raw form. This option is also used to exclude other non-essential keys that need not be recorded.

<Note>
  **Note:**

  *The records for the `country` and `city` columns are blacklisted for ingestion because SPL uses the user's IP address to find out the country and city automatically. For the complete list of blacklisted fields, click [here](/articles/integrate-customer/blacklisted-fields-for-data-ingestion).*
</Note>

### Login and Identities Settings

Enter the following details to configure the login and identities settings:

* **Login Event** – Choose the `dataLayer` event that is fired on user login.

* **Are your identities hashed?** – Based on whether you want your identities to be hashed or not, perform one of the following actions:

  * *If your identities are hashed –* Select this checkbox and make the following selections for the identities:

    * **Hashed Email**– Select the **Capture hashed email** checkbox and then proceed to add a row for the hash algorithm. Click **Add Row** and then choose the appropriate **Hash Algorithm** and its corresponding **Hashed Email Variable** from the drop-down menus. You can add more rows as per your requirement.
    * **Hashed Cellphone with country code** – Select the **Capture hashed cellphone number with country code** checkbox and then proceed to add a row for the hash algorithm. Click **Add Row** and then choose the appropriate **Hash Algorithm** and its corresponding **Hashed Cellphone Number Variable** from the drop-down menus. You can add more rows as per your requirement.
    * **Hashed Loginid** – Select the **Capture hashed Loginid** checkbox and then proceed to add a row for the hash algorithm. Click **Add Row** and then choose the appropriate **Hash Algorithm** and its corresponding **Hashed Loginid Variable** from the drop-down menus. You can add more rows as per your requirement.

  * *If your identities are not hashed –* Then do not select this checkbox and proceed to the next option.

* **Is hashing of raw identities required?**– Based on whether you want to hash the raw identities or not, perform one of the following actions:

  * *If hashing of the raw identities is required – Select this checkbox and make the following selections for the identities:*

    * **Raw Email**– Select the **Capture Email** checkbox and then choose the appropriate **Email Variable** from the drop-down menu.
    * **Raw Cellphone with country code**– Select the **Capture cellphone number with country code** checkbox and then choose the appropriate **Cell number variable** from the drop-down menu.
    * **Raw Loginid**– Select the **Capture Loginid** checkbox and then choose the appropriate **Loginid Variable** from the drop-down menu.
      <Frame>
        <img src="https://mintcdn.com/zeotap/puXmsvA7x0OblYvo/articles/integrate-customer/Storage/integrate-customer/project-collect-internal/hashing_rawid_req_new.png?fit=max&auto=format&n=puXmsvA7x0OblYvo&q=85&s=45e7cc492bd288d9a5a668b2c5319dec" width="1706" height="838" data-path="articles/integrate-customer/Storage/integrate-customer/project-collect-internal/hashing_rawid_req_new.png" />
      </Frame>
  * *If hashing of the raw identities is not required –* Then do not select this checkbox and proceed to the next option.

    <Note>
      **Note:**

      To know about the hashing guidelines for email and cell phone numbers, refer [here](https://docs.zeotap.com/smart/project-unify/hashing-guidelines).
    </Note>

* **Create First Party ID+ cookie on user login** – If you are a Publisher who is using Zeotap's ID+ services, then ensure to select this checkbox to activate the ID+ calls.

* **Organisation partner ID** – This ID is provided by Zeotap after enabling ID+ for your organisation. Ensure that the ID is properly added.

* **User Logout** – Specify the `dataLayer` event that captures the user logout. The same event is used to unset the email address, phone number or loginid from the subsequent events.

* **User Attributes** – Specify the `dataLayer` variables that contain user-related information. The same variable is passed in the `setUserProperties` call.
  <Frame>
    <img src="https://mintcdn.com/zeotap/puXmsvA7x0OblYvo/articles/integrate-customer/Storage/integrate-customer/project-collect-internal/creat_frstpartyid_cookie_new.png?fit=max&auto=format&n=puXmsvA7x0OblYvo&q=85&s=7d96af164759ceeb80278d69b73d788a" width="1706" height="498" data-path="articles/integrate-customer/Storage/integrate-customer/project-collect-internal/creat_frstpartyid_cookie_new.png" />
  </Frame>

### Google Analytics Configuration

If you want to capture IDs relating to your Google Analytics (GA) account for ID completeness, reporting or outward integration (for example, `Optimize360`), you can configure the settings in this section to capture the same.

* **Pick Google Analytics client ID** – Select this checkbox if you want the Zeotap tag to pick the Google Analytics client ID that is used for user identification.

  * **GA Client ID Cookie Prefix** – If your GA cookie is configured with a cookie prefix, you can add the same here. For example, a typical GA cookie that was named `_ga`, may be configured with a brand name prefix User ID variable in your GA settings, you can configure the corresponding cookie name here.
* **Use only for Login Event** – If this checkbox is selected, then the GA User ID is attached only for the post-login events.

### Advanced Settings

Under the **Advanced Settings** section, choose the **Once per event** option from the **Tag firing** drop-down menu. At this moment, we only support this option. Note that under the **Advanced Settings** section you need not make any other selection.

## Step 4 - Set up the Trigger

The inputs for the template help the tag to track all the relevant events happening on the web application. So the recommended trigger would be for all the real events that you want to capture using the tag.

The following are the various events for which you can fire the tag:

* If you want to fire the tag only for tracking page views, then use the **All Pages** built-in trigger.
* If you want to fire the tag to capture all the events, then use the **All Events** trigger.

You can either add a preconfigured trigger to a tag or create a trigger within the tag. The section below explains the two methods in detail.

### Method 1

Perform the following steps to set up the trigger as mentioned in Method 1:

<Steps>
  <Step>
    Go to the **Trigger Configuration** section from your left menu.
  </Step>

  <Step>
    Click **New** to add a trigger.
  </Step>

  <Step>
    Provide a descriptive name for the Trigger.
  </Step>

  <Step>
    Click anywhere on the Trigger Configuration block. This will open up the **Choose trigger type** slider window on the screen.
  </Step>

  <Step>
    Under **Other**, choose **Custom Event** as the **Trigger Type**.
  </Step>

  <Step>
    Type 'Login event' as the event name.
  </Step>

  <Step>
    Select the **Use regex matching** checkbox to add your own regex, if your events follow a specific naming convention. Type `^(?!gtm\.load)(?!gtm\.dom).*` if you want to set this regex for all the events.

    <Note>
      **Note:**

      This regex sets the trigger for all the events except GTM's internal events, gtm.load and gtm.dom.
    </Note>
  </Step>

  <Step>
    Select the **All Custom Events** radio button. Note that the trigger is set for the login event only.
  </Step>

  <Step>
    Click **Save**.

    <Frame>
      <img src="https://mintcdn.com/zeotap/puXmsvA7x0OblYvo/articles/integrate-customer/Storage/integrate-customer/project-collect-internal/CD/attachments/2665775403/2693628920.png?fit=max&auto=format&n=puXmsvA7x0OblYvo&q=85&s=7e15436ef96056620c9ef918f752c0ff" width="1600" height="735" data-path="articles/integrate-customer/Storage/integrate-customer/project-collect-internal/CD/attachments/2665775403/2693628920.png" />
    </Frame>
  </Step>

  <Step>
    In the Tag addition, add this as the trigger for the Zeotap Collect tag. This means, our JS will fire an event collection call for each event on the website.

    <Frame>
      <img src="https://mintcdn.com/zeotap/puXmsvA7x0OblYvo/articles/integrate-customer/Storage/integrate-customer/project-collect-internal/CD/attachments/2665775403/2693268628.png?fit=max&auto=format&n=puXmsvA7x0OblYvo&q=85&s=498b988fc0b74888346b37a899302d94" width="1600" height="428" data-path="articles/integrate-customer/Storage/integrate-customer/project-collect-internal/CD/attachments/2665775403/2693268628.png" />
    </Frame>
  </Step>
</Steps>

### Method 2

Perform the following steps to set up the trigger as mentioned in Method 2:

You can also set a trigger to a tag while configuring it. Perform the following steps to set a trigger to a tag from the **Tag Configuration** section.

<Steps>
  <Step>
    Navigate to the **Tag Configuration** section of the tag to which you want to attach a trigger.
  </Step>

  <Step>
    Click **+** under the **Triggering** section.
  </Step>

  <Step>
    In the **Choose a trigger** window that appears click **+**.
  </Step>

  <Step>
    Choose **Custom Event** as the **Trigger Type**.
  </Step>

  <Step>
    Type your 'Login event' as the event name.
  </Step>

  <Step>
    Select the **Use regex matching** checkbox to add your own regex, if your events follow a specific naming convention. Type `^(?!gtm\.load)(?!gtm\.dom).*` if you want to set this regex for all the events.

    <Note>
      **Note:**

      This regex sets the trigger for all the events except GTM's internal events, `gtm.load` and `gtm.dom`.
    </Note>
  </Step>

  <Step>
    Select the **All Custom Events** radio button. The trigger is set for the login event only.
  </Step>
</Steps>

## Step 5 - Validate the Configured Collect Tag

After you have added the Zeotap Collect Tag, configure the same and set the trigger to perform the following steps to evaluate how it works:

<Steps>
  <Step>
    Click **Tags** from the left menu. Of all the tags that are listed, ensure that your tag is in an inactive state and has not been paused.
  </Step>

  <Step>
    Click the **Preview** button that appears on the top right corner. You are taken to the **Tag Assistant** page.
  </Step>

  <Step>
    In the **Google Tag Assistant** window that appears, enter the website where you have integrated the GTM and then click **Start**. Refer to the image below from a sample website.
  </Step>

  <Step>
    You are redirected to the website URL that you had entered. Perform any action of the website.
  </Step>

  <Step>
    After performing any action on the website, right-click on the web page and click **Inspect**.
  </Step>

  <Step>
    Go to the **Console** tab of the **DevTools** window that opens and under **dataLayer** look for the event name that you have configured.
  </Step>

  <Step>
    Go back to the **Tag Assistant** window and click **Continue**.
  </Step>

  <Step>
    Under **Tags Fired** you can find the tag that was fired.
  </Step>
</Steps>
