Set up Google Tag Manager with GA4

  • Updated

Follow these steps to add Google Tag Manager to your Google Analytics 4 Web Property:

Google Tag Manager implementation requires a testing process. Optimizely recommends that you implement Tag Manager on your Sandbox site first and verify accurate tracking of user events before recreating the tracking on your Production site. You must complete the following steps twice: once for Sandbox and once for Production.

Default tags included in Optimizely’s template tag container

Setting up Google Tag Manager includes a template container with a set of tags that 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 linked at the bottom of this article.

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)

Sign in to Tag Manager and create a new container for GA4

When transitioning from Universal Analytics to GA4, you should create a new container for GA4 in the Tag Manager account you used for Universal Analytics. For both Universal Analytics and GA4, you should use the Tag Manager's Default Workspace.

  1. Sign in to your Tag Manager account.
  2. Find your Universal Analytics Tag Manager account.
  3. Click More (...) beside the account, and select Create Container
  4. Enter a name for your new container, such as "My Website Name - GA4 Container".
  5. Select Web as the Target platform.
  6. Click Create.

A pop-up appears 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. Using the same container allows you to have all UA tags until Google ends support for UA in July 2023. However, using the same container creates 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 Admin 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 click Default Workspace.
  4. Select Merge and Rename conflicting tags, triggers, and variables.
  5. Click Confirm.
  6. Click Tags in the left menu. This page provides a list of the tags included in the container. The json file tags have unique names starting with GA4 to differentiate the old tags from GA4 tags.
  7. 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.
  8. Click Save
  9. Click Submit
  10. Put today's date under Version Name so you can track when these changes were published.
  11. Click Publish.
  12. Click Tags in the left menu.
  13. Review the list and ensure that there is only one Tag with the Type of Google Analytics: GA4 Configuration. There should only be one tag with this type: the tag included in the Optimizely Default Contained entitled GA4 - Pageview. Delete or disable any other Tag with this type.

Json files