Setting up web tracking with GTM

How it works

This guide will provide step-by-step instructions on how you can set up your Data Talks Web Tracking using Google Tag Manager (GTM). To do so, you need to create and configure our web behavioral GTM container.

In this guide we are going to create a new container, attach the Snowplow Custom Templates and create a functioning tag for the Page View events. In addition, the document provides the optional configuration required in order to capture the email of a logged in user.

Requirements

  • Google Account
  • Add the container code into your website
  • Capture email address (optional)
    • Add the Data Layer code into your website
    • Provide the required values to the Data Layer

Create an account

  1. First, go to https://tagmanager.google.com to start the setup for the Google Tag Manager (GTM) and login with your Google credentials.
Create an account in GTM set up
GTM Landing page
  1. After logging in, you need to create your account in GTM. NOTE: If you already have a container created for your account, you can skip this step and proceed directly to “The Setup process” below.
    1. Fill the Account Name, Country and the Container Name fields accordingly. We will choose “Web” as the Target Platform.
    2. Accept the Data Processing Terms by marking the checkbox at the bottom left and then Accept the GTM Terms of Service by pressing the Yes button on the top right corner.
How to create an account in GTM
Create Account

The setup process

In order to make the GTM configuration as easy and fast as possible, you can use the attached .json files. They contain a template container configuration. By importing them to your GTM container you are able to set up your web tracking in just a few clicks. Continue to follow this guide to set it up correctly.

Files List

  1. First, start by visiting the Admin tab from the GTM navigation bar. If you log in to GTM and end up in the Workspace section, you will find the Admin tab to the right-hand side.
Click Admin tab
  1. By doing so, you will be directed to this menu (image below). In the right column, there is an option called Import Container. That is the option you need to select in order to proceed.
GTM Container Admin Page
  1. Next, you will be presented with a few options displayed in the following image that will be explained one by one below.
Import Container Page
  1. Select file to import
    1. Click the Choose container file button and select the .json file. appropriate for you.
  2. Choose workspace
    1. Select Existing and Default Workspace.
Select Workspace
  1. Choose an import option
    1. If you do not have any other configuration within your GTM configuration, in other words your container is empty, choose to Overwrite
    2. In case you have configured their GTM container before, select Merge. Additionally, in the Merge option, select the Overwrite conflicting tags, triggers, and variables.
Import Container page before Confirmation
  1. Finally, select Confirm.

There are a few changes you need to make in order to configure the container. Depending on the actions/tags you want to include in the container, you will have to make the following changes. The change included under Page View is required for every type of configuration.

Page View

  1. From the Variables menu, choose User-Defined Variables, and then choose Snowplow Analytics Settings. We need to change the value of the Application ID. More information about the Application ID and its naming can be found below:
Application ID

Each domain you create will receive an application ID, a unique identifier we will use to recognize and connect the visits to your site(s). Since the naming is unique, we will need to specify what kind of website you use. You will be able to select the following based on the most matching business purpose your website serves.

There are some naming rules you need to follow. You need to keep the name short, and suggestively include the most descriptive (and recognizable) part of your name, followed by a hyphen ( – ) and then a suffix. The following list can indicate the available suffixes:

  • main
    • Used for the main websites.
  • shop
    • Used for webshops.
  • membership
    • Used for membership websites. 
  • news
    • Used for newsletter subscription websites or similar
  • ott
    • Used for Over-The-Top media services websites
Page View Configuration

User Login

Except for the changes described under Page View, there is no other change required for this type of action/tag. However, you still need to add the script below. In order for this data to appear in the CDP, you need to contact your Customer Success Manager. 

window.addEventListener("load", function(){
              window.dataLayer = window.dataLayer || [];
              window.dataLayer.push({
                    "event" : "login",
                    "userId": "email-address-value-in-string-format" 
                });
            });

Form tracking

From the Triggers menu, choose Form Submit. You need to change the third value (in this case you need to replace the word demo) to a unique word contained within the page URL of the form you want to track. In order for this data to appear in the CDP, you need to contact your Customer Success Manager.

Form Tracking Configuration

Frequently Asked Questions

Q: What is the functionality of each tag you can install?

A: There are two tags, one for each functionality:

  • Pageview tag: Pageview event is being fired every time a user visits a page within the website (a reload of the same page is considered a new pageview event). As long as they remain for more than 10 seconds, another event will be fired called page ping. This event is being used to calculate the time spent within a single page or even the overall session within the website.
  • Form tracking tag: An event of type unstructured will be fired when the user submits a form from the webpage specified within the Google Tag Manager container.

Q: What data will be captured with each tag you install?

A: There are data generated by the tracker itself and there are data retrieved from the page.

  • Tracker generated data:
    • Application Id: A unique identifier specified via Google Tag Manager container, important for identifying the origin of the received data.
    • Domain User Id: A unique identifier stored in a cookie for this specific browser, so we can identify the user later on, even in a different session.
    • User Id: A unique identifier which is being used for assigning an email address for the logged in users. Empty if not specified.
    • Event Id: A unique identifier for each event sent to our pipeline.
    • Domain Session Id: A unique identifier used to group events based on the session of a user.
    • Timestamp: Timestamp of the fired event in UTC.
  • Retrieved from the page:
    • Page Title
    • Page URL (We also receive on separate fields the URL path, port, query, scheme, fragment)
    • Page Referrer (Similar to Page URL, we additionally receive on separate fields URL referrer host, path, port, scheme, fragment, medium, source, term)
    • Browser Name
    • Operating System Name

Q: Is there any Personally Identifiable Information (PII) data that can be captured?

A: The only personally identifiable information we receive is the email address, but that is only applicable if the user is logged in and the log-in web tracking configuration is in place.

How to pick a file

Here you will find some use cases, so you can easily determine which file to pick. The time spent is included in the page view tag.

Case 1:

You have a main website and want to track page views and the time spent within every page view. In addition, you have previously configured a Google Analytics solution, which is still active, in the provided GTM container.

Solution:

To onboard yourself into our web tracking solution, you only have to import the page_view.json file. In this case, during the Overwrite/Merge procedure, you need to select Merge and Overwrite conflicting tags, triggers and variables. Don’t select Overwrite here, because that would remove the existing tags from your GA configuration. After importing the file you have to configure the value for the Application ID. Once this is done, publish the changes and your web tracking is live.

Case 2:

You have a main website and want to track page views, time spent within every page view and form submissions. You have no prior configurations in your GTM container. 

Solution:

To onboard yourself into our web tracking solution you need to import the page_view.json file and the form_tracking.json file. First, start with the import of the page view file. Here you have the option to select either Overwrite or Merge. It will have no effect on this specific container since it’s empty. After configuring the Application ID, the next step is to import the form tracking file. Here you need to select Merge and Overwrite conflicting tags, triggers, and variables. Do not select Overwrite, because it would remove the tag/trigger/variable created by the page view file import. Finally, you can configure the third value in the Form-Submit trigger. Once this is done, publish the changes and your web tracking is live.

Case 3:

You’ve already implemented web tracking for your webshop. Currently, you’re tracking page views and the time spent, but you want to add user login tracking.

Solution:

To add the user login functionality to an existing page view configuration, you need to import the user_login.json file. Here we select Merge and Overwrite conflicting tags, triggers, and variables. It is important we overwrite the existing page view tag, so it will receive the extra configuration for the tag sequencing, coming from the user_login.json file. Once this is done, publish the changes.

Case 4:

You’ve already implemented web tracking for your main website. You are already tracking page views, time spent and an existing contact form. Recently you added a newsletter subscription form and you want to track this form too.

Solution:

Adding the form tracking to the existing container requires a bit more configuration:

  1. First, you need to rename the existing tag, trigger and variable in order to be able to import again the form_tracking.json file. In other words, you need to rename the Form-Tracking tag, the Form-Submit trigger and the form-tracking variable to something that is close to the same meaning. For example, you could add the suffix contact. So the values would be, Form-Tracking-Contact, Form-Submit-Contact and form-tracking-contact. That way, you will be able to import the form_tracking.json file, select Merge and  Overwrite conflicting tags, triggers and variables. And have both forms configured at the same time. 
  2. To make it even better with the distinction of the forms, it would be better after the import to add a suffix to the newly added form. A possible option could be Form-Tracking-Newsletter, Form-Submit-Newsletter, or form-tracking-newsletter. 
  3. Finally, you configure the third value of the Form-Submit-Newsletter trigger. Once this is done, publish the changes.

Case 5:

You have a webshop and want to track page views, the time spent within every page view, a contact form as well as the logged-in users.  In addition, you have previously configured a Google Analytics solution, which is still active, in the provided GTM container.

Solution:

To onboard yourself into our web tracking solution you need to import the user_login.json and the form_tracking.json files. We are omitting the page_view.json, because the user_login.json not only covers everything the page_view.json provides, but also adds the user login functionality. In case you want to add the page views tracking AND user login tracking you can directly import the user_login.json file. Starting with the import of the user login file, select Merge and Overwrite conflicting tags, triggers and variables. Then configure the value of the Application ID. Next, import the form tracking file and select Merge and Overwrite conflicting tags, triggers and variables. Finally, configure the third value in the Form-Submit trigger. Once this is done, publish the changes and your web tracking is live.

Powered by BetterDocs

Arrow-up