Set up Google Tag Manager with GA4

  • Updated

Implementation of Google Analytics requires a testing process. Optimizely recommends that you implement Google Analytics on your Sandbox site first and verify accurate tracking of user events before recreating the tracking on your Production site. The following steps will need to be completed twice: once for Sandbox and once for Production.

  1. Sign in to your Tag Manager account and Create a new Container for GA4.
  2. Import Optimizely’s default json file into your GA4 container.
  3. Verify that the Google Tag Manager snippet is installed on your site.

Sign into Tag Manager and create a new Container for GA4

When transitioning from Universal Analytics to GA4, it is best to create a new Container for GA4 within the same Tag Manager account that was used for Universal Analytics. For both Universal Analytics and GA4, you should use the Tag Manager's Default Workspace.

  1. Sign into your Tag Manager account here: Google Tag Manager homepage
  2. Find the Tag Manager account that was used with your Universal Analytics instance. Click on the triple dot menu to the right of that account, and select Create Container
  3. On the Create Container pop-up screen, enter a name for your new Container, such as "My Website Name - GA4 Container".
  4. Select Web as the Target platform. Click Create.
  5. A pop-up will appear with the Install Google Tag Manager instructions. You can close this box. 

Although Optimizely recommends that you create a new container for GA4, you can use your existing UA container. 

  • The benefit of using the same container is that you have all UA tags until Google ends support for UA in July 2023. 
  • The drawback of using the same container is that you receive two sets of several tags, which may cause confusion. Additionally, you must merge the Digital Self Service Pageview Lookup_1 variable with the Digital Self Service Pageview Lookup variable.

Import default tags into your GA4 Container

  1. Click the Admin tab on the top menu. 
  2. Go to Container > Import Container. Import the Spire-ga4-container.json file in this article.
  3. Select Existing workspace, and then click on the Default Workspace.
  4. Select Merge and Rename conflicting tags, triggers, and variables. Click Confirm.
  5. Click Tags. This page provides a list of the tags included in the Container. The tags included in the json file have been given unique names starting with GA4 to make it easy to differentiate the old tags from GA4 tags.
  6. Click on the GA4 - Pageview tag. Under Measurement ID, ensure that the number shown is the Measurement ID for your Google Analytics account. If not, click the Edit icon, and update the Measurement ID to match your Google Analytics Account. Click Save
  7. Click Submit at the top right. 
  8. Put today's date under Version Name so you can track when these changes were published. Click Publish.

Verify that the Google Tag Manager snippet is installed on your Configured Commerce site

To start tracking by Google Analytics and Tag Manager, you must install the Google Tag Manager snippet on your Configured Commerce site via the Configured Commerce Admin Console. The Google Tag Manager snippet is linked to Google Analytics and will provide tracking for both GA4 and GTM.

The Tag Manager snippet for Google Analytics 4 and Universal Analytics should be the same if you are using the same Tag Manager account.

You can find the Google Tag Manager snippet by following the below instructions:

    • Log into Tag Manager at this link https://tagmanager.google.com/#/home
    • Select the Account and Container that relates to your GA4 setup under All accounts.
    • Select the Admin tab, then click Install Google Tag Manager. Copy and paste tag manager ID (i.e. GTM-####).

Install the Google Tag Manager snippet in the Admin Console of Configured Commerce. You can review the documentation on installing Google Tag Manager if you need help.

Appendix: Default tags included in Optimizely’s template tag container

Setting up Google Tag Manager includes a template container with a set of tags that will help you get your Tag Manager site up and running. This section explains the details of the tags included in that container and refers to the json file entitled Spire-ga4-container.json.

The Tags provided in the template container are designed to work for B2B Analytics. Changes to the CSS may affect the behavior of these tags and should be tested and/or reviewed by your implementation partner or someone knowledgeable about Google Analytics 4 before being pushed to production.

  • Tags related to PageView Navigation: These tags are maintained in the variables setup called Digital Self Service Pageview Lookup and under the name GA4 – Event – Self-Service.
    • myaccount
    • catalog
    • contactus
    • orders
    • requestaccount
    • dealerlocator
  • Tags related to Lists
    • create list (GA4 – Event – createList)
    • add to list (GA4 – Event – addToList)
    • share list (GA4 – Event – shareList)
  • Tags related to Orders
    • quickorder (GA4 – Event – QuickOrder)
    • reorder button (GA4 – Event – reorderButton)
    • upload order (GA4 – Event – UploadOrder)
  • Tags related to Search
    • search Event (GA4 – Event – Search Results)
    • search Autocomplete Event (GA4 – Event – Search Autocomplete Results)
  • Tags related to Downloading Content
    • download content (pdf, jpg, xlsx, doc) (GA4 – Event – File Download)

Json files