Step 2. Configure your Google Tag Manager account

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.

NOTE
For additional information, see Google’s Container export and import. These instructions provide a walk-through for importing a sample JSON in a new container.
  1. 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.

  2. Navigate to Admin > Container > Import Container.

  3. Click Choose container file and select the json file.

  4. Under Choose workspace, click New.

  5. Enter a title and description, then click Save.

  6. To import the file, select one of the following actions:

    • The Overwrite option should be selected for a new container.

    • The Merge option should be selected if you are using an existing container.

  7. Click Preview to review the tags, triggers, and variables.

  8. 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.

  9. Follow Google’s instructions for adding 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.

  10. Click Confirm when complete.

  11. Follow Google’s instructions for publishing the new container.

Step 3. Configure your store

NOTE
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.
  1. Log in to the Admin of your Commerce store.

  2. On the Admin sidebar, go to Stores > Settings > Configuration.

  3. In the left panel, expand Sales and choose Google API.

  4. Expand Expansion selector the Google Analytics section and configure the following:

    Sales configuration - Google Analytics

    • 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.

  5. When complete, click Save Config.

  6. Test your Google Tag Manager settings and verify that everything works correctly.

NOTE
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.

Field descriptions

FieldScopeDescription
EnableStore ViewDetermines if Google Analytics Enhanced Ecommerce can be used to analyze activity in your store. Options: Yes / No
Account typeStore ViewDetermines the Google tracking code that is used to monitor store activity and traffic. Options: Google Analytics / Google Tag Manager
Anonymize IPStore ViewDetermines if identifying information is removed from IP addresses that appear in Google Analytics results.
Enable Content ExperimentsStore ViewActivates Google Content Experiments, which can be used to test up to ten different versions of the same page. Options: Yes / No
Container IdStore ViewIf Google Tag Manager is already installed and configured for your store, the Container ID appears automatically in this field.
List property for the catalog pageStore ViewIdentifies the Tag Manager property associated with the catalog page. Default value: Catalog Page
List property for the cross-sell blockStore ViewIdentifies the Tag Manager property associated with the cross-sell block. Default value: Cross-sell
List property for the up-sell blockStore ViewIdentifies the Tag Manager property associated with the up-sell block. Default value: Up-sell
List property for the related products blockStore ViewIdentifies the Tag Manager property associated with the related products block. Default value: Related Products
List property for the search results pageStore ViewIdentifies the Tag Manager property associated with the search results page. Default value: Search Results
“Internal Promotions” for promotions field “Label”Store ViewIdentifies the Tag Manager property associated with the labels for internal promotions. Default value: Label

Create a tag for tracking conversions

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.

Step 1. Create a tag

  1. Log in to your Google Tag Manager account and click the link for the container that you created for your store.

  2. In the New Tag box, click Add a new tag.

  3. Get the following information from your AdWords account:

    • Conversion ID
    • Conversion Label

    If you need help, visit Google’s support site.

  4. 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.

  5. Enter the Conversion ID and Conversion Label from your AdWords account and click Continue.

Step 2. Create a rule

Continuing from the Google Tag Manager dashboard, the next step is to create a rule that fires the tag on the conversion page.

  1. Under Fire On, click Some Pages.

  2. 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 the Google Tag Manager Help.

    • Value - checkout/success.*

  3. Select the green checkbox and click Save.

    The trigger that you set up appears as a blue button in the Fire On section.

  4. When complete, click Save Tag.

Step 3. Preview and publish

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.

Previous pageGoogle Analytics
Next pageGoogle Adwords

Commerce