Google Tag Manager helps you manage the many tags, or snippets of code, that are related to your marketing campaign events. Google Tag Manager gives you the ability to add tracking tags to your site to measure the audience, or to personalize, retarget, or conduct search engine marketing initiatives.
Google Tag Manager directly transfers data and events to Google Analytics, Enhanced Ecommerce, and other third-party analytics solutions to produce a clear picture of how well your site, products, and promotions are performing.
You should have a Google Analytics and Tag Manager account to continue this process. The following instructions walk you through the process of configuring your Google accounts, configuring your Commerce store, and creating a tag.
If your business is subject to privacy regulations such as the General Data Protection Regulation and/or the California Consumer Privacy Act, see Google Privacy Settings.
See Set up Site Search in Google Help for the basics you need to get started. Also see the Google guides for Google Analytics and Google Tag Manager.
Sign in to your Google Analytics account.
To enable Internal Site Search Tracking, do the following:
Navigate to Select View > View Settings.
Set Site Search Tracking to On
.
Set Query parameter to q
.
When complete, Save the settings.
To enable display features, do the following:
Choose Property Settings.
Under Advertising Features, set Enable Demographics and Interest Reports to On
.
Save the settings.
To enable Ecommerce Tracking, do the following:
Navigate to Select View > Ecommerce Settings.
Set Enable Ecommerce to On
.
Set Enable Enhanced Ecommerce Reporting to On
.
Save the settings.
Reload the page to verify that all the settings remain On
.
If not all settings are On
, repeat the previous steps, save, and reload the page. Repeat this process until all settings are set to On
.
The following instructions show how to configure a new container with the basic settings. A sample Composer configuration (.json) file is used to simplify the process, importing to generate a tag in a new container. For this example, creating a container, rather than modify an existing container, is recommended.
For additional information, see Google’s [Container export and import][5]. These instructions walk-through importing a sample JSON to a new container.
Download the linked file GTM_M2_Config_json.txt, open the file in an editor, and save it as GTM_M2_Config.json
.
The json file is uploaded directly to Google Tag Manager.
Navigate to Admin > Container > Import Container.
Click Choose container file and select the json file.
Under Choose workspace, click New.
Enter a title and description, then click Save.
Select one of the following actions to import the file:
The Overwrite option should be selected for a new container.
The Merge option should be selected if you are using an existing container.
Click Preview to review the tags, triggers, and variables.
To edit the Google Analytics ID that is referenced in variables, do the following:
Navigate to Variables > User-Defined Variables.
Choose Google Analytics and update the placeholder (UA-xxxxxx-x
) with your own GA ID.
Follow Google’s instructions to add tags, triggers, and variables to the new container.
If you have settings in another container that you want to use, they can be moved to the new container.
Click Confirm when complete.
Follow Google’s instructions to publish the new container.
Starting with the 2.4.5 release, the Google services integration is updated to support use of the GTag APIs. GTag is a unified mechanism for integration with Google functionality for web pages and supports the newest capabilities and opportunities for tracking and managing content through Google Services. For more information, see the Google Analytics developer documentation.
Log in to the Admin of your Commerce store.
On the Admin sidebar, go to Stores > Settings > Configuration.
In the left panel, expand Sales and choose Google API.
Expand the Google Analytics section and configure the following:
Set Enable to Yes
.
Set Account type to Google Tag Manager
.
In the Container ID field, enter your GTM ID (GTM-xxxxxx
).
If you are also using Google Analytics to content experiments, set Enable Content Experiments to Yes
.
Use the default values for the remaining fields.
When complete, click Save Config.
Test your Google Tag Manager settings to verify that everything works correctly.
Each container is associated with one website and you only need one container per account. If you have a multi-site Commerce instance, you need separate containers.
To copy the GTM code, go to Admin > Install Google Tag Manager.
There are two GTM code snippets to be added to your Commerce site: the first one for the <head>
tag and the second for the <body>
tag.
In the Commerce Admin, go to Content > Design > Configuration and open the store view in edit mode.
Under Other Settings, expand HTML Head and paste the code you copied from GTM for the <head>
tag in the Scripts and Style Sheets field.
Expand Footer and paste the GTM code for <body>
in the Miscellaneous HTML field.
When complete, click Save Configuration.
Field | Scope | Description |
---|---|---|
Enable | Store View | Determines if Google Analytics Enhanced Ecommerce can be used to analyze activity in your store. Options: Yes / No |
Account type | Store View | Determines the Google tracking code that is used to monitor store activity and traffic. Options: Google Analytics / Google Tag Manager |
Anonymize IP | Store View | Determines if identifying information is removed from IP addresses that appear in Google Analytics results. |
Enable Content Experiments | Store View | Activates Google Content Experiments, which can be used to test up to ten different versions of the same page. Options: Yes / No |
Container Id | Store View | If Google Tag Manager is already installed and configured for your store, the Container ID appears automatically in this field. |
List property for the catalog page | Store View | Identifies the Tag Manager property associated with the catalog page. Default value: Catalog Page |
List property for the cross-sell block | Store View | Identifies the Tag Manager property associated with the cross-sell block. Default value: Cross-sell |
List property for the up-sell block | Store View | Identifies the Tag Manager property associated with the up-sell block. Default value: Up-sell |
List property for the related products block | Store View | Identifies the Tag Manager property associated with the related products block. Default value: Related Products |
List property for the search results page | Store View | Identifies the Tag Manager property associated with the search results page. Default value: Search Results |
“Internal Promotions” for promotions field “Label” | Store View | Identifies the Tag Manager property associated with the labels for internal promotions. Default value: Label |
If you have a Google AdWords account, you can create a tag that tracks conversions. The following example shows how to use both Google Tag Manager and Google Analytics to create a tag that fires on your store’s conversion Success"_ page.
Log in to your Google Tag Manager account and click the link for the container that you created for your store.
In the New Tag box, click Add a new tag.
Get the following information from your AdWords account:
If you need help, visit Google’s support site.
From the Google Tag Manager dashboard, click Google AdWords and do the following:
Click the title placeholder and enter a name for the new tag.
Under Choose Product, select Google AdWords.
Under Choose a Tag Type, select AdWords Conversion Tracking and click Continue.
Enter the Conversion ID and Conversion Label from your AdWords account and click Continue.
Continuing from the Google Tag Manager dashboard, the next step is to create a rule that fires the tag on the conversion page.
Under Fire On, click Some Pages.
In the Choose Pages section, complete the following settings:
Name - Enter a name for the page description.
Variable url
Operation - matches RegEx
To learn more, see Regex and CSS selector operators in Tag Manager Help.
Value - checkout/success.*
Select the green checkbox and click Save.
The trigger that you set up appears as a blue button in the Fire On section.
When complete, click Save Tag.
The next step in the process is to preview the tag. Each time the tag is previewed, a snapshot of the version is saved. When you are satisfied with the results, go to the version that you want to use and click Publish.