WiscWeb - WordPress UW Theme - Adding Google Analytics to a Website Using Google Tag Manager
This document provides instructions for adding Google Analytics to a website using Google Tag Manager.
- Support: Support is not available from the UW-Madison Google team for non-core apps. We recommend the following for assistance:
- Recommendation: Use a departmental service account when using non-core apps to share ownership of data and avoid losing access to data owned by a former employee/student.
Google Tag Manager is used to track events that users trigger when visiting your website. One of the things that can be tracked via Tag Manager is your Google Analytics. You can then use the Google Analytics trigger later on for other events (such as file downloads, link clicks, etc.).
Reminder: Always use an Office 365 Service Account to create your Google Analytics and Google Tag Manager accounts.
- In Google Tag Manager, navigate to your Workspace Tab.
- From your Workspace Tab, navigate to Tags and click the button labeled, New.
- Name your new tag something appropriate, like "GA Page Views", set the Tag Type to “Google Analytics - Universal Analytics," and the Track Type to "Page View."
- In the Google Analytics Settings drop down, click that and select "New Variable." Give this variable an appropriate name, like "GA Analytics Code" and enter your Google Analytics Tracking ID value into the Tracking ID field.
Click into the Triggering section, and select "All Pages." This will tell this tag to trigger on every page within your site.
- You can find your UA Tracking ID under “Property Settings” in the Admin section of your Google Analytics account.
Click Save in the upper right section of your tag.
With your Tag and Variable created and saved, you are returned to your Workspace. From here you need to publish your changes by clicking on the Submit button in the upper right section of the window. You will be prompted twice to enter information about these changes - this is good for keeping track of the updates that you make in case you don't remember.
Once you’ve published your Google Tag Manager container, you can add it to your WordPress customizer area by taking the Tag Manager Tracking ID (usually GTM-XXXXXXX) and putting it into your Customizer area (Appearance --> Customize --> Analytics). You can remove your Google Analytics Tracking ID, and then Publish your changes to commit them to your site.