In order for your analytics account to collect data, our analytics JavaScript with your analytics ID (UA tracking ID/GA4 measurement ID) needs to be on every page of your website. How you apply our analytics JavaScript to your entire site will depend on if your website is managed by:
-
- Our CAWeb Team
- Your agency
CAWeb managed websites
If our CAWeb Team manages your website, we will add your analytics ID to every page of your site. We will also confirm that your analytics account is collecting data.
To confirm your analytics ID is applied to your site:
-
- Log in to manage your site.
- Go to CAWeb Theme Options.
- Under the General Settings tab, expand the Google section.
- There should be an ID in the Analytics ID and Analytics 4 ID fields.
Agency managed websites
If you are an agency managing your own site, you will need to add our analytics JavaScript to every page of your website. Our CAWeb Team will provide you with your agency analytics ID to include in our analytics JavaScript – this will ensure data is collected into your analytics account.
California State Web Template setup
If your agency is using the most recent version of our California State Web Template, our analytics JavaScript is already part of your files. To collect analytics to your account, you will need to:
-
- From the template files, open and edit /ssi/analytics.html file.
- Replace the default analytics ID(s) with your agency ID(s):
- Universal Analytics (UA): Replace UA-20973992-30 on line 4 and line 15 with your agency property tracking ID
- Google Analytics 4 (GA4): Replace G-75V2BNQ3DR on line 42 and 49 with your agency measurement ID
- Save changes and push to production per your department standards.
Custom template setup
If you are using your own custom template, you will need to add our JavaScript into the <head> tag section of every page on your website. To collect analytics to your account, you will need to:
-
- Copy and paste the JavaScript code below into the <head> tag section of every page on your website. We recommend you paste it in right before the closing </head> tag.
- Replace the default analytics ID(s) with your agency ID(s):
- UA: Replace UA-20973992-30 with your agency property tracking ID
- GA4: Replace G-75V2BNQ3DR with your agency measurement ID
- Save changes and push to production per your department standards.
JavaScript code
Google Analytics 4
<!--Google Analytics 4 --> <script async src="https://www.googletagmanager.com/gtag/js?id=G-75V2BNQ3DR"></script> <script> window.dataLayer = window.dataLayer || []; function gtag(){dataLayer.push(arguments);} gtag('js', new Date()); gtag('config', 'G-69TD0KNT0F'); // statewide GA4 measurement ID gtag('config', 'G-75V2BNQ3DR'); // individual agency GA4 measurement ID </script>
Universal Analytics
<!-- Universal Analytics --> <script async src="https://www.googletagmanager.com/gtag/js?id=UA-20973992-30"></script> <script> window.dataLayer = window.dataLayer || []; function gtag(){dataLayer.push(arguments);} gtag('js', new Date()); //statewide GA property gtag('config', 'UA-3419582-2'); //please update state department UA code in line below before deployment gtag('config', 'UA-20973992-30'); var getOutboundLink = function(url) { gtag('event', 'click', { 'event_category': 'navigation', 'event_label': 'outbound link: ' + url, 'transport_type': 'beacon', 'event_callback': function(){document.location = url;} }); } var trackDownload = function(filename) { gtag('event', 'click', { 'event_category': 'download', 'event_label': 'file: ' + filename, 'transport_type': 'beacon', 'event_callback': function(){document.location = url;} }); } </script>
Contact our CAWeb Team through ServiceNow if you have any issues implementing the new code.
Google Tag Manager
Some agencies prefer to leverage Google Tag Manager (GTM) to add their Google Analytics ID onto their website. If you’d like to use GTM to add your Google Analytics ID(s) to your site, visit our Use Google Tag Manager to Add Google Analytics page.
Confirm you’re collecting data
Once your analytics ID(s) is in production, you will need to confirm your analytics account is collecting data. Log in to your Google Analytics account, and then confirm your account is collecting data by either:
-
- Going to Reports > Realtime and confirming pages you are actively visiting show up under:
- Top Active Pages (UA)
- Views by Page title and screen name (GA4)
- Waiting 24 hours for analytics to display in your Google Analytics Reports dashboard
- Behavior > Site Content > All Pages (UA)
- Life cycle > Engagement > Pages and screens (GA4)
- Going to Reports > Realtime and confirming pages you are actively visiting show up under: