Send events to Google Tag Manager using RudderStack web device mode.
3 minute read
After you have successfully instrumented Google Tag Manager as a destination in RudderStack, follow this guide to correctly send your events to Google Tag Manager in device mode.
Find the open source JavaScript SDK code for this integration in the GitHub repository.
Identify
You can use the identify call to identify a user, and send their information like name, email, etc. to Google Tag Manager.
The above call populates Google Tag Manager with a traits object containing all user traits (like name, gender, city, etc.)
Page
You must call the page event to load Google Tag Manager.
The page call allows you to record whenever a user visits a page of your website, along with the properties associated with that page.
When you make a page call, RudderStack sends an object to the GTM data layer containing your page-related properties and an event name with its associated value. All properties you pass in the page call are spread into the data layer object.
Event naming logic
The integration automatically generates an event name for the GTM data layer based on the page name and category you provide. The event naming logic is explained below:
Condition
Event name
Only page name is provided
Viewed {name} page
Page name and category are provided
Viewed {category} {name} page
No page name is provided
Viewed a Page
Some examples of how event names are generated based on the above conditions are shown below:
This site uses cookies to improve your experience while you navigate through the website. Out of
these
cookies, the cookies that are categorized as necessary are stored on your browser as they are as
essential
for the working of basic functionalities of the website. We also use third-party cookies that
help
us
analyze and understand how you use this website. These cookies will be stored in your browser
only
with
your
consent. You also have the option to opt-out of these cookies. But opting out of some of these
cookies
may
have an effect on your browsing experience.
Necessary
Always Enabled
Necessary cookies are absolutely essential for the website to function properly. This
category only includes cookies that ensures basic functionalities and security
features of the website. These cookies do not store any personal information.
This site uses cookies to improve your experience. If you want to
learn more about cookies and why we use them, visit our cookie
policy. We'll assume you're ok with this, but you can opt-out if you wish Cookie Settings.