Welcome to the OpenCities help centre. Search for what you're after, or browse the categories.
Can't find what you're looking for? Submit a support ticket and we'll be in touch.


Start gathering data with Google Analytics 4

avatar of Kira Hartley

Kira Hartley

Last updated

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.

  1. Log into your existing Google Analytics account and go to the Admin settings by selecting the gear icon in the bottom-left corner.
  2. Select Create Property and give it a name differentiating it from your UA property. You can also select a Reporting time zone and Currency.
  3. Select Next, specify any Business information you want to include, and then select Create.
  4. Now, set up a data stream by selecting Web.
  5. Enter your Website URL and a Stream name and select Create stream.
  6. 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>
      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');
    The script should now contain your UA Tracking ID and GA4 Measurement ID.
  7. Now go to your OpenCities site admin, then More > Site Management > your site > Settings > Site Settings.
  8. Scroll down and paste the sample script into the Google analytics field.
  9. Select Save Settings, then Save.

Your site should now be collecting data from your GA4 property and the UA property.

Was this article helpful?
3 out of 4 found this helpful