You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/connections/destinations/catalog/google-tag-manager/index.md
+10-11Lines changed: 10 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,38 +9,37 @@ id: 54521fd625e721e32a72eeb9
9
9
10
10
## Getting Started
11
11
12
-
{% include content/connection-modes.md %}
13
12
14
13
1. From the Segment web app, click **Catalog**.
15
14
2. Search for "Google Tag Manager" in the Catalog, select it, and choose which of your sources to connect the destination to.
16
15
3. In your Segment UI's destination settings, enter your Container ID (note: it should start with "GTM-"). You can find this in the Admin section of your [GTM dashboard](https://tagmanager.google.com/#/admin/).
17
-
4. GTM will be loaded on any pages where your Segment snippet is initialized and `analytics.page`gets called in client-side Javascript. Once you've turned on GTM through Segment, you can use Segment `track` events to populate the GTM `dataLayer`.
16
+
4. GTM loads on any pages where your Segment snippet is initialized and `analytics.page`is called in client-side Javascript. Once you've turned on GTM through Segment, you can use Segment `track` events to populate the GTM `dataLayer`, and remove the GTML snippet from your page.
18
17
19
18
**Notes**
20
-
*We recommend loading GTM through Segment rather than loading Segment inside of GTM.
19
+
*Segment recommends that you load GTM through Segment rather than loading Segment inside of GTM.
21
20
* Be sure to "publish" your GTM container in GTM before trying to load it through Segment, otherwise your container URL will return a 404 error.
22
21
23
22
24
23
## Page
25
24
If you're not familiar with the Segment Specs, take a look to understand what the [Page method](/docs/connections/spec/page/) does. An example call would look like:
26
25
27
26
```js
28
-
analytics.page('Home', {
27
+
analytics.page('Home', {
29
28
title:'Welcome | My Website',
30
29
url:'https://mywebsite.com/'
31
30
});
32
31
```
33
32
34
-
You must call the Page method for Google Tag Manager to load. We already include a call to `analytics.page` in your default Segment snippet, so if you haven't removed that, GTM will work the same as if you installed the GTM snippet directly.
33
+
You must call the Page method for Google Tag Manager to load. Segment includes a call to `analytics.page` in your default Segment snippet, so if you haven't removed that, GTM will work the same as if you installed the GTM snippet directly.
35
34
36
35
### Tracking All Pages
37
-
When you turn on the setting to **Track All Pages** in your Optional Settings, we will track events whenever you call our`page` method and send a "Loaded A Page" event to Google Tag Manager. See the `track` section below for more info on how we send events to GTM.
36
+
When you turn on the setting to **Track All Pages** in your Optional Settings, Segment tracks events whenever you call the`page` method and send a "Loaded A Page" event to Google Tag Manager. See the `track` section below for more info on how Segment sends events to GTM.
38
37
39
38
### Named Page Events
40
-
If you include a `name` parameter in your `page` calls and turn on the setting to **Track Named Pages** in your Optional Settings, we will also pass on an event to GTM for that page. For example, `analytics.page('Signup')` would translate to a "Viewed Signup Page" event. See the `track` section below for more info on how we send events to GTM.
39
+
If you include a `name` parameter in your `page` calls and turn on the setting to **Track Named Pages** in your Optional Settings, Segment passes on an event to GTM for that page. For example, `analytics.page('Sign up')` would translate to a "Viewed Sign up Page" event. See the `track` section below for more info about how Segment sends events to GTM.
41
40
42
41
### Categorized Page Events
43
-
If you include a `category` parameter in your `page` calls and turn on the setting to **Track Categorized Pages** in your Optional Settings, we will also pass on an event to GTM for that page. For example, `analytics.page('Docs', 'Index')` would translate to a "Viewed Docs Index Page" event. See the `track` section below for more info on how we send events to GTM.
42
+
If you include a `category` parameter in your `page` calls and turn on the setting to **Track Categorized Pages** in your Optional Settings, Segment passes an event to GTM for that page. For example, `analytics.page('Docs', 'Index')` would translate to a "Viewed Docs Index Page" event. See the `track` section below for more info about how Segment sends events to GTM.
We will pass it to the `dataLayer` as an object like this:
67
+
Segment it to the `dataLayer` as an object like this:
69
68
70
69
```json
71
70
{
@@ -86,7 +85,7 @@ If you are seeing `404` error on the javascript console of your page and it is a
86
85
## Appendices
87
86
88
87
### UserId and AnonymousId
89
-
By default we will also push the `anonymousId` and `userId`(if exists) into the `dataLayer` for each `page` or `track` call. Since the `anonymousId` is created by Segment, we will namespace that property in the `dataLayer` as `segmentAnonymousId`.
88
+
By default Segment pushes the `anonymousId` and `userId`(if exists) into the `dataLayer` for each `page` or `track` call. Since the `anonymousId` is created by Segment, namespaces that property in the `dataLayer` as `segmentAnonymousId`.
90
89
91
90
### Environments
92
91
If you're using an 'environment' variable for `gtm_preview` in your tag's query string, you can set that string in the **Environment** of your Optional Settings. IMPORTANT: Make sure the string includes the `gtm_auth` variable. For example, your string should look like: `env-xxxxx>m_auth=xxxxx`.
0 commit comments