Skip to content

Commit b4d89a4

Browse files
committed
Add docs for GTM v4
1 parent 8035f87 commit b4d89a4

File tree

68 files changed

+1320
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+1320
-0
lines changed

docs/data-product-studio/snowtype/working-with-gtm/index.md

+7
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,13 @@ The code that Snowtype will generate is included in a `snowplow.js` file and, as
6666
Below you can see the steps you need to create the variable using the contents generated by Snowtype:
6767
![](./images/gtm-var.gif)
6868

69+
70+
:::warning
71+
72+
If the generated code is too large for Google Tag Manager, you can split it into multiple variables and include them in the order they are generated, or place directly into a Custom HTML tag.
73+
74+
:::
75+
6976
### Naming and calling the Custom JavaScript
7077

7178
After selecting a name for the Custom JavaScript variable, you would need to include it in a [Custom HTML](https://support.google.com/tagmanager/answer/6107167?hl=en#CustomHTML) tag so that it is executed. Depending on your Google Tag Manager setup, there are a couple, or more, places the variable can be used. An example is a type of Custom HTML tag that runs during page initialization:
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
---
2+
title: Ecommerce Tag Configuration
3+
sidebar_position: 100
4+
---
5+
6+
```mdx-code-block
7+
import Tabs from '@theme/Tabs';
8+
import TabItem from '@theme/TabItem';
9+
```
10+
11+
## Ecommerce API
12+
13+
Use the native Snowplow Ecommerce API or [transitional GA4/UA ecommerce adapter APIs](/docs/sources/trackers/javascript-trackers/web-tracker/tracking-events/ecommerce/index.md) for existing dataLayer implementations using those formats. To get full value from the [Snowplow Ecommerce plugin](/docs/sources/trackers/javascript-trackers/web-tracker/tracking-events/ecommerce/index.md) we recommend using the native API when possible.
14+
15+
![](images/01_ecommerce_api.png)
16+
17+
## Tracking Parameters
18+
19+
<Tabs groupId="ecommerceAPI" queryString>
20+
<TabItem value="sp" label="Snowplow Ecommerce" default>
21+
22+
![](images/02_sp_tracking_parameters.png)
23+
24+
#### Snowplow Ecommerce Function
25+
26+
In this section you can select the [Snowplow Ecommerce function](/docs/sources/trackers/javascript-trackers/web-tracker/tracking-events/ecommerce/index.md) to use.
27+
28+
#### Snowplow Ecommerce Argument
29+
30+
In this textbox you can specify the argument to the ecommerce function. This can be a Variable that evaluates to a corresponding object.
31+
32+
#### Additional Tracking Parameters
33+
34+
**Add Custom Context Entities**
35+
36+
Use this table to attach [custom context entities](/docs/sources/trackers/javascript-trackers/web-tracker/tracking-events/index.md#custom-context) to the Snowplow event. Each row can be set to a Google Tag Manager variable that returns an array of custom contexts to add to the event hit.
37+
38+
**Set Custom Timestamp**
39+
40+
Set this to a UNIX timestamp in case you want to [override the default timestamp](/docs/sources/trackers/javascript-trackers/web-tracker/tracking-events/index.md#setting-the-true-timestamp) used by Snowplow.
41+
42+
</TabItem>
43+
<TabItem value="ga4" label="GA4 Ecommerce">
44+
45+
![](images/02_ga4_tracking_parameters.png)
46+
47+
#### GA4 Ecommerce Function
48+
49+
In this section you can select the [Google Analytics 4 Ecommerce function](/docs/sources/trackers/javascript-trackers/web-tracker/tracking-events/ecommerce/index.md) to use.
50+
51+
#### GA4 Ecommerce Arguments
52+
53+
**DataLayer ecommerce**
54+
55+
Here you can specify the dataLayer ecommerce variable to use, i.e. a variable that returns the `ecommerce` object itself.
56+
57+
**Options object**
58+
59+
Here you can specify a variable returning an object holding additional information for the ecommerce event (e.g. including `currency`, `finalCartValue`, `step`, etc).
60+
61+
</TabItem>
62+
<TabItem value="ua" label="Universal Analytics Enhanced Ecommerce">
63+
64+
![](images/02_ua_tracking_parameters.png)
65+
66+
#### Universal Analytics Enhanced Ecommerce Function
67+
68+
In this section you can select the [Universal Analytics Enhanced Ecommerce function](/docs/sources/trackers/javascript-trackers/web-tracker/tracking-events/ecommerce/index.md) to use.
69+
70+
#### Universal Analytics Enhanced Ecommerce Arguments
71+
72+
**DataLayer ecommerce**
73+
74+
Here you can specify the dataLayer ecommerce variable to use.
75+
76+
**Options object**
77+
78+
Here you can specify a variable returning an object holding additional information for the ecommerce event (e.g.including currency, finalCartValue, step etc).
79+
80+
</TabItem>
81+
</Tabs>
82+
83+
## Snowplow Tracker and Ecommerce Plugin Settings
84+
85+
![](images/04_tracker_plugin_settings.png)
86+
87+
### Tracker Settings
88+
89+
The Snowplow Ecommerce tag template **requires** a Snowplow Settings Variable to be setup. In this section you can select the Google Tag Manager variable of type [Snowplow Settings](/docs/sources/trackers/google-tag-manager/quick-start/index.md) to use.
90+
91+
### Plugin Settings
92+
93+
In this section you can select how the plugin will be added. The available options are:
94+
95+
- **jsDelivr**: To get the plugin URL from jsDelivr CDN. Choosing this option allows you to specify the plugin version to be used.
96+
- **unpkg**: To get the plugin URL from unpkg CDN. Choosing this option allows you to specify the plugin version to be used.
97+
- **Self-hosted**: To get the plugin library from a specified URL. This option requires a [Permission](https://developers.google.com/tag-platform/tag-manager/templates/permissions) change to allow injecting the plugin script from the specified URL.
98+
- **Do not add**: To not add the plugin (e.g. when using a [Custom Bundle](/docs/sources/trackers/javascript-trackers/web-tracker/plugins/configuring-tracker-plugins/index.md) with the plugin already included)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
---
2+
title: Ecommerce Template
3+
sidebar_position: 600
4+
---
5+
6+
This template implements the [Snowplow Ecommerce plugin](/docs/sources/trackers/google-tag-manager/ecommerce-tag-template) for the Snowplow JavaScript tracker and is meant to be used alongside [the main Snowplow tag template](/docs/sources/trackers/google-tag-manager/quick-start/index.md#snowplow-tag-template).
7+
8+
## Template Installation
9+
10+
To manually install the tag template:
11+
12+
1. Download [template.tpl](https://github.com/snowplow/snowplow-gtm-tag-template-ecommerce-v3)
13+
2. Create a new Tag template in the Templates section of your GTM container
14+
3. Click the More Actions menu and select Import
15+
4. Import the `template.tpl` file downloaded in Step 1
16+
5. Click Save
17+
18+
## Tag Setup
19+
20+
With the template installed, you can now add the Snowplow Ecommerce Tag to your GTM Container.
21+
22+
1. From the Tag tab, select `New`, then select the Snowplow Ecommerce Tag as your tag type
23+
2. Select your desired Trigger for the ecommerce events you want to track
24+
3. [Configure the Tag]
25+
4. Click Save
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
---
2+
title: "Google Tag Manager"
3+
date: "2020-08-10"
4+
sidebar_position: 3100
5+
---
6+
7+
8+
```mdx-code-block
9+
import Badges from '@site/src/components/Badges';
10+
11+
<Badges badgeType="Actively Maintained"></Badges>
12+
```
13+
14+
Using the Snowplow GTM custom templates you can now deploy, implement, and configure the Snowplow JavaScript tracker directly on the website using Google Tag Manager.
15+
16+
The main Tag template that you will need to use when setting up the JavaScript Tracker v4 in GTM is available in the [Tag Manager Template Gallery](https://tagmanager.google.com/gallery/#/owners/snowplow/templates/snowplow-gtm-tag-template-v4). To setup the Snowplow v4 Tag, you will also need the Snowplow v4 Settings Variable template. The templates you will need are:
17+
18+
1. [Snowplow v4 Settings](https://tagmanager.google.com/gallery/#/owners/snowplow/templates/snowplow-gtm-variable-template-v4):
19+
A variable template which can be used to easily apply a set of tracker configuration parameters to tags created with the Snowplow v4 tag template.
20+
2. [Snowplow v4](https://tagmanager.google.com/gallery/#/owners/snowplow/templates/snowplow-gtm-tag-template-v4):
21+
Load, configure, and deploy the Snowplow JavaScript tracker library. It supports the full functionality of the JavaScript SDK.
22+
23+
```mdx-code-block
24+
import DocCardList from '@theme/DocCardList';
25+
26+
<DocCardList />
27+
```
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
---
2+
title: "Plugins"
3+
sidebar_position: 300
4+
---
5+
6+
[Plugins](/docs/sources/trackers/google-tag-manager/plugins/index.md) provide an easy way to distribute custom behavior for the tracker.
7+
Each Plugin can be loaded from external URLs or provided inline within GTM, and can optionally take some custom configuration.
8+
A Plugin may add new methods to the tracker that can be called via [Custom Commands](#custom-commands).
9+
10+
:::note
11+
12+
Snowplow Plugins are updated alongside the tracker SDK to ensure compatibility. For best results, keep the SDK and plugin versions in sync:
13+
14+
- CDN Users: Use a GTM Variable to manage versions in URLs.
15+
- Self-Hosting: Update plugin files whenever you update the SDK.
16+
17+
:::
18+
19+
## `Load Plugins` table
20+
21+
Plugins are configured by using the **Load Plugins** table, within the Snowplow tag. Each row takes three values to load a plugin.
22+
23+
:::tip
24+
25+
Plugins are loaded by the tracker SDK directly, not via the Tag Template:
26+
You do not need to adjust the Template permissions to allow loading plugins from these URLs.
27+
28+
:::
29+
30+
### Plugin URL
31+
32+
The URL to load the Plugin from, e.g. `https://cdn.jsdelivr.net/npm/@snowplow/browser-plugin-link-click-tracking@latest/dist/index.umd.min.js`
33+
34+
The tracker will try to load plugins each time they are requested.
35+
This is usually acceptable as the browser will have cached the first request; if you don't want this behavior we suggest creating an empty **Custom Command** Tag with no commands that loads the plugins; you can make this Tag fire [once per page](https://support.google.com/tagmanager/answer/6279951) and add it as a [Setup Tag](https://support.google.com/tagmanager/answer/6238868) to any other Tags that use its commands.
36+
37+
### Plugin Configuration
38+
39+
The name of the Plugin to load. These values can be found on the respective plugin documentation.
40+
41+
For example, for the `Link Click Tracking` plugin, the values (`'snowplowLinkClickTracking,LinkClickTrackingPlugin'`) can be found in the snippet [here](https://docs.snowplow.io/docs/sources/trackers/javascript-trackers/web-tracker/tracking-events/link-click/#enable-link-click-tracking).
42+
43+
### Additional Configuration (optional)
44+
45+
Finally, the optional **Additional Configuration** field allows you to add any configuration the Plugin may require.
46+
47+
There are two ways to format additional configuration:
48+
49+
- A single comma-seperated string value, which will be split into an array of strings and passed as arguments to the Plugin. (e.g. `arg1,arg2,arg3`)
50+
- A reference to a GTM Variable containing an Array of arguments to pass to the Plugin.
51+
52+
Plugins are loaded in order, and processed before the configured **Tag Type** configuration is executed -- so you can load a plugin in the same Tag that uses its functionality via Custom Commands.
53+
54+
The plugins will remain configured in the tracker and be accessible to later Tags.
55+
56+
:::warning
57+
58+
The Tag Template will try to call `.indexOf(',')` on the **Additional Configuration** value, so values of types other than Array or String may fail and break the Tag.
59+
String values (before or after splitting) of `true`, `false`, `null`, and numeric values will become their respective typed JSON values.
60+
It is not possible to pass a single `null`, `undefined`, or empty string value as a parameter to a Plugin, instead no arguments will be passed to the plugin.
61+
62+
:::
63+
64+
## Inline Plugins
65+
66+
[Inline Plugins](/docs/sources/trackers/javascript-trackers/web-tracker/plugins/creating-your-own-plugins/index.md#inline-plugins) are plugins that don't require being fetched from an external file to load.
67+
68+
You can create Inline Plugins in GTM by using Custom JavaScript Variables in the **Plugin URL** field.
69+
The Variable should return an Object with a method that returns another Object meeting the [Plugin Interface](/docs/sources/trackers/javascript-trackers/web-tracker/plugins/creating-your-own-plugins/index.md#plugin-interface) (any other methods on the outer Object will become tracker methods).
70+
71+
For **Plugin Configuration**, the UI enforces the comma-seperated values syntax required for external Plugins and unconditionally calls `.split(',')` on the string.
72+
The SDK requires that for inline-plugins only a single string may be used.
73+
To work around this limitation, create another Custom JavaScript Variable that returns your constructor method name wrapped in an Object with a fake `split()` method:
74+
75+
```javascript
76+
function() {
77+
return {
78+
split: function() {
79+
return "myInlineConstructorMethodName";
80+
}
81+
};
82+
}
83+
```
84+
85+
:::info
86+
87+
If your configuration includes functions, GTM will wrap those functions in [its sandbox](https://developers.google.com/tag-platform/tag-manager/templates/sandboxed-javascript), even when passed to the SDK for execution.
88+
89+
Complex values like DOM elements will be replaced by `null` when passed to or returned from your function, which may make some plugins not function as intended.
90+
91+
:::
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
title: "Previous versions"
3+
sidebar_position: 1000
4+
---
5+
6+
In this section you can find out more about the Google Tag Manager custom templates for deploying the previous (v2/v3) versions of the Snowplow JavaScript tracker.
7+
8+
```mdx-code-block
9+
import DocCardList from '@theme/DocCardList';
10+
11+
<DocCardList />
12+
```
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
---
2+
title: v2
3+
date: "2021-11-18"
4+
sidebar_position: 1000
5+
---
6+
7+
Snowplow JavaScript Tracker v2 can now be deployed directly with Google Tag Manager via a Custom Template. This is available in the [Tag Manager Template Gallery](https://tagmanager.google.com/gallery/#/owners/snowplow/templates/snowplow-gtm-custom-template).
8+
9+
There are two templates that you will need to use when setting up the Template for JavaScript Tracker v2.
10+
11+
1. [Snowplow Analytics Settings](https://tagmanager.google.com/gallery/#/owners/snowplow/templates/snowplow-gtm-custom-template-settings)
12+
2. [Snowplow Analytics](https://tagmanager.google.com/gallery/#/owners/snowplow/templates/snowplow-gtm-custom-template)
13+
14+
Snowplow Analytics Settings Template: A variable template which can be used to easily apply a set of tracker configuration parameters to tags created with the Snowplow Analytics tag template.
15+
16+
Snowplow Analytics Template: Load, configure, and deploy the Snowplow JavaScript tracker library. It supports the full functionality of the JavaScript SDK.
17+
18+
These Custom Templates were created by [Simo Ahava](https://www.simoahava.com/), full documentation can be found on his site:
19+
20+
- [Snowplow Analytics Settings Template Documentation](https://www.simoahava.com/custom-templates/snowplow-analytics-settings/)
21+
- [Snowplow Analytics Template Documentation](https://www.simoahava.com/custom-templates/snowplow-analytics/)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
---
2+
title: "Snowplow v3 Settings Variable"
3+
sidebar_position: 2000
4+
---
5+
6+
The **Snowplow v3 Settings** custom variable template is meant to be used with the Snowplow v3 tag template.
7+
8+
With this template, you can compile a **tracker configuration object**, which you can then load into your Snowplow tags to avoid the need to manually enter the same tracker settings across all your tags.
9+
10+
## Install the template
11+
12+
To **install the template**, browse to **Templates** in the Google Tag Manager user interface.
13+
14+
Under **Variable Templates**, click **Search Gallery**, and type `Snowplow v3` into the gallery overlay search bar.
15+
16+
![search Snowplow v3 Settings in GTM gallery](images/search_snowplow_v3_settings.png)
17+
18+
Click the **Snowplow v3 Settings** template name, and then click **Add to Workspace** in the next screen. Review the permissions and click **Add** to finalize the import.
19+
20+
After importing the template, you can follow the normal process of creating a **new variable** in Google Tag Manager, and the **Snowplow v3 Settings** template will be listed among the **Custom** variable types you can choose from.
21+
22+
## Instructions
23+
24+
The fields in the template provide a UI for setting the tracker configuration parameters. You are thus encouraged to follow [this link](/docs/sources/trackers/javascript-trackers/web-tracker/tracker-setup/initialization-options/index.md) to understand what each individual field does.
25+
26+
### Tracker Name
27+
28+
It is important to set the **tracker name**. The reason you might have more than one tracker name generated on the site is if you have different configuration objects or tracking endpoints to which you want to send commands.
29+
30+
When the tag runs, it first checks if a tag with this name has already been initialized. If it has, it then proceeds to send the command to this tracker name. If a tracker with this name has _not_ been initialized, a new tracker is initialized with the tracker configuration from this settings variable.
31+
32+
This means that a tracker configuration is applied **only once** to the tracker. Thus if you have more than one tag running on the site, each with the same tracker name but different tracker configurations, only the configuration of the tag that fires _first_ will be applied to the tracker.
33+
34+
### Collector Endpoint Hostname
35+
36+
This needs to be set to the hostname/domain (e.g. `sp.domain.com`) on which you’ve configured your [Snowplow Collector](/docs/pipeline/collector).
37+
38+
## Acknowledgements
39+
40+
Thanks to [Simo Ahava](https://www.simoahava.com/) for building the intial release of this template.

0 commit comments

Comments
 (0)