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.
- Sign in to your Tag Manager account and Create a new Container for GA4.
- Import Optimizely’s default json file into your GA4 container.
- 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.
- Sign into your Tag Manager account here: Google Tag Manager homepage
- 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.
- On the Create Container pop-up screen, enter a name for your new Container, such as "My Website Name - GA4 Container".
- Select Web as the Target platform. Click Create.
- A pop-up will appear with the Install Google Tag Manager instructions. You can close this box.
Import default tags into your GA4 Container
- Click the Admin tab on the top menu.
- Go to Container > Import Container. Import the Spire-ga4-container.json file in this article.
- Select Existing workspace, and then click on the Default Workspace.
- Select Merge and Rename conflicting tags, triggers, and variables. Click Confirm.
- 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.
- 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.
- Click Submit at the top right.
- 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.
- 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)