Google Tag Manager (GTM) Templates

Introduction

Google Tag Manager is a free tool that enables marketers to install, store, and manage marketing tags without modifying website code, and instantly deploy tags on your website or mobile app from an easy-to-use web-based interface. 

MoEngage <> Google Tag Manager

With the MoEngage and Google Tag Manager integration, you can deploy the MoEngage Web SDK and leverage all its capabilities without writing any code on your website.

Integration via Web SDK

library_add_check

Prerequisites

Ensure you have a Google Tag Manager account with permission to import templates and add new tags.

There are two Google Tag Manager templates built by MoEngage, the Initialization Tag and the Actions Tag. Both tags can be added to your workspace by importing them from the Templates section.

Import the templates into your GTM Workspace

Step 1: Download and import the two tags:

  1. Download the Initialization Tag and the Actions Tag (right-click and Save).
  2. To import the tag into your GTM workspace, go to the Templates screen from the left side menu.
    Screenshot
  3. Under Tag Templates, click on the "New" button >> Actions menu (top-right) >> Import. Select the Initialization tag file you just downloaded.
  4. Click save when you see the MoEngage logo on the left.
  5. Do the same for the Actions tag as well.

Initialization tag

The Initialization tag is used to add the MoEngage Web SDK to your website. This will enable you to take full advantage of the MoEngage native setup.

Step 1: Select and configure the Initialisation Tag

Screenshot

  1. On your GTM dashboard, click on Tags >> New.
  2. Click on Tag Configuration, and under "Custom" look for the MoEngage initialization tag.
  3. Setup the tag according to your needs:
Property Value
App ID App ID of your MoEngage account. You can find this by navigating to Settings -> App Settings
Debug Logs
  • True - if you want the logs to be shown on the console
  • False - if you want to hide the logs (make sure you select False for production website)
warning

   Critical - When Going Live

While pushing the code to live website please ensure debug_logs: 0 is initialized to send website data to LIVE MoEngage Dashboard (top toggle switch on Dashboard to right).

Data center

Your MoEngage Data Center region (DC_X).

  • DC_1
  • DC_2
  • DC_3
  • DC_4
Serviceworker custom path The path of your service worker file. Read more about setting up Push notifications support here.
Is Onsite-Messaging disabled?

On-site Messaging Campaigns allow you to show personalized pop-ups and non-intrusive banners on your website.

Web SDK integration for On-site Messaging will automatically start working on all the pages where the web SDK is integrated. 


If you want to disable Onsite-Messaging for this website, check this option. Read more about how to configure Onsite-Messaging here.

Is SPA enabled? If your website is a Single Page Application (SPA), select this option. Read more about how MoEngage handles SPAs here.
Enable Web Personalization Web Personalization is used to personalize the website experience for each user. Select this option if you want to leverage our Web Personalization capabilities. Read more about Web Personalization here

If you want to personalize cards, paste the JSON config in here. Read more about how to customise cards according to your needs here.

Step 2 (Optional): Enabling Web Push notification

Optionally, if you want to be able to send push through the Google Tag Manager, first follow the push integration guidelines and place serviceworker file at the root directory of your project.

Step 3: Triggering

After configuring the tag, trigger it at every page view of your site:

Screenshot

This will ensure the MoEngage Web SDK is initialized on every page of your website.

Actions tag

The MoEngage Actions Tag template lets you trigger custom events, update custom as well as standard user attributes, and add or update user IDs.

Step 1: Select and configure the Actions Tag:

Screenshot

  1. On your GTM dashboard, click on Tags >> New.
  2. Click on Tag Configuration, and under "Custom" look for the MoEngage Actions Tag.
  3. Setup the tag according to your needs.

The MoEngage Actions tag can be used to perform any of the following actions using the MoEngage Web SDK:

Track Custom Event

In order to track custom events, select the Tag Type as "Track Custom Event".

Property Value
Tag type Select "Track Custom Event".
Event Name The name of the event that you want to track. Note that standard events are automatically tracked by the SDK.
Event Attributes

Here you can specify additional event attributes that you want to track along with this event.

For each attribute, click on "Add Row" and then provide:

  1. Attribute Name: The name of the custom attribute
  2. Attribute Value: The value of the custom attribute. You can also use variables here.

Track Custom User Attributes

In order to track custom user attributes, select the Tag Type as "Track Custom User Attributes".

Property Value
Tag type Select "Track Custom User Attributes".
Attribute Name The name of the custom attribute that you want to track.
Attribute Value

The value of the custom attribute. You can also use variables here.

Login

In order to log the user in, select the Tag Type as "Login".

Property Value
Tag type Select "Login".
User ID The User ID of the user that has performed the login. This will be used to identify the user on MoEngage.

Logout

In order to log the user out, select the Tag Type as "Logout".

Property Value
Tag type Select "Logout".

Update User ID

In order to update an existing User ID of the logged-in user, select the Tag Type as "Update User ID".

Property Value
Tag type Select "Update User ID".
User ID The updated User ID of the user is being tracked.

Read more about how updating the User ID of a user works in MoEngage.

Track Standard Attribute

In order to track a standard attribute, select the Tag Type as one of the following:

  1. Track First Name
  2. Track Last Name
  3. Track Email
  4. Track Mobile
  5. Track Username
  6. Track Gender
  7. Track Date of Birth
Property Value
Tag type Select "Track First Name/Last Name/Email/Mobile/Username/Gender/Date of Birth".
Value The value of the standard attribute you selected.

Read more about updating the standard attributes of a user in MoEngage.

Step 2: Triggering

After configuring the tag, trigger it at the appropriate point on your website. This will depend on whether you want to track a custom event, or login/logout a user.

Integration via GTM Server Side

You can also forward the events captured on your GTM server to MoEngage without writing any code on your website. Read more about how to set up the integration with GTM Server and MoEngage on our help docs.

Previous

Next

Was this article helpful?
2 out of 7 found this helpful

How can we improve this article?