Setting up Google Analytics
The Basics
Section titled “The Basics”For testing, make sure any adblock is turned off.
- Set up the Google Analytics 4 ID
- Ideal: Use your agency partner’s Google Analytics account
- Ask your agency IT partners whether they have a Google Analytics account, and their preference on using an existing property vs. setting up a new one
- See if you/your team can gain access to their Google Analytics account so you can view metrics
- Secondary Option: If for any reason you won’t be able to access a GA4 ID set up through your agency in time, you can set one up via OOI’s property.
- Create an Operations Request ticket
- Make sure to indicate who will need access to the GA4 property. Typically this is the PM and engineers on the team to troubleshoot & debug the analytics set-up. For viewing analytics on an ongoing basis, we typically will set up a Looker dashboard. View Example
- Ideal: Use your agency partner’s Google Analytics account
- Get access to the OIT Google Tag Manager Container
- If you or your teammates don’t yet have access to OIT’s GTM container, email OIT web publishing requesting access to the shared NJ GTM instance.
- Only the people that will be actively updating GTM will need access here. Ideally, the PM and at least one engineer on the team has access.
- If you or your teammates don’t yet have access to OIT’s GTM container, email OIT web publishing requesting access to the shared NJ GTM instance.
- Create a new workspace for your changes (if one is available; if not, use the default workspace)
- Once you are provisioned access, you can go to Tag manager to manage GTM.
- Creating workspaces
- Add the GTM container code to your website (requires engineering support)
- To access the code, visit tagmanager.google.com, under the “State of New Jersey” account, click on the
www.nj.govcontainer, select your workspace, and finally, in the top right of the menu bar, click on the link readingGTM-P3V3PJ6. This will open up a modal with instructions on code to add. - See the index.html of the AI Assistant for an example.
- To access the code, visit tagmanager.google.com, under the “State of New Jersey” account, click on the
- Add the Google Tag via GTM (You’ll need the GA4 ID to set this up correctly)
- Confirm via the “Preview” that the GA4 ID is being fired correctly. You can also check this in the “Realtime” analytics.
- Optional: Manage your event tagging
- Many things will already be automatically captured, such as users, sessions, and views
- If you require custom events, follow these instructions
- General steps:
- Align on event definition and parameters as a team. Note: Documenting the custom event names and parameters in a spreadsheet can help the team stay aligned on what events are being tracked and implemented from code to GTM. For an example, see the AI Assistant tracker, particularly columns G and H.
- Engineering to implement the events within the application’s JavaScript code
- Then, PM or Engineering can configure the tag and triggers within GTM
- General steps:
- Once the GA ID and any desired custom event tracking is added, email OIT web publishing to publish the tag. This step is important; without this, you will not capture analytics.
- They typically have a quick turnaround, within a few hours to a day, but make sure to build in some time here ahead of launch.
- It will take 24-48 hours for analytics reports to start populating, but to confirm the tags once they are live, you can use the “Realtime” reporting within Google Analytics.
- For custom dashboards, Looker Studio dashboards can be set up (by Engineering) after Google Analytics is implemented and added (note that it takes 24-48 hours to start seeing new events in Looker). In the meantime, you can see analytics reporting within Google Analytics itself. For an example, see the AI Assistant Looker Studio dashboard
Best Practices
Section titled “Best Practices”- Test any changes using the “Preview” functionality
- Use “Folders” to organize your tags, variables, and triggers
- Use a standard naming convention for tags, variables, and triggers to make them easy to search