This task is for users with the following roles: OC Site Manager and OC System Administrator.
By July 1st, 2023, all Universal Analytics (UA) properties will stop processing data to make way for Google Analytics 4 (GA4). You can start dual tagging, allowing you to begin capturing data for when Universal Analytics becomes obsolete. We have also made it possible to use a GA4 property with the Insights Dashboard.
You'll need a UA and a GA4 property to continue with these instructions. If you've never connected your site before, check out our article on how to connect OpenCities with Google Analytics.
Currently, you can start collating data about the most popular and trending pages, top task views and suggestions, and popular and low-performing search results.
To get started with GA4, you'll first need to create a GA4 property in your existing Google Analytics account, then update the Google analytics script in your OpenCities Site Settings.
- Log into your existing Google Analytics account and go to the Admin settings by selecting the gear icon in the bottom-left corner.
- Select Create Property and give it a name differentiating it from your UA property. You can also select a Reporting time zone and Currency.
- Select Next, specify any Business information you want to include, and then select Create.
- Now, set up a data stream by selecting Web.
- Enter your Website URL and a Stream name and select Create stream.
- You'll see the Web stream details page. Copy the Measurement ID from here and enter it into this script, replacing the bold text GA4-CODE-GOES-HERE. If you haven't already, you'll need to replace the bold text UA-CODE-GOES-HERE with your UA property Tracking ID (note that there are two places into which the Tracking ID needs to go).
<!-- Global site tag (gtag.js) - Google Analytics --> <script async src="https://www.googletagmanager.com/gtag/js?id=UA-CODE-GOES-HERE"></script> <script> window.dataLayer = window.dataLayer || []; function gtag(){dataLayer.push(arguments);} gtag('js', new Date()); gtag('config', 'GA4-CODE-GOES-HERE'); gtag('config', 'UA-CODE-GOES-HERE'); </script>
The script should now contain your UA Tracking ID and GA4 Measurement ID. - Now go to your OpenCities site admin, then More > Site Management > your site > Settings > Site Settings.
- Scroll down and paste the sample script into the Google analytics field.
- Select Save Settings, then Save.
Your site should now be collecting data from your GA4 property and the UA property.