Getting started - Google Analytics 4 configuration

How to configure and use the Site Analytics app for SharePoint Online by Accelerator 365

The Site Analytics app from Accelerator 365 integrates your SharePoint sites with Google Analytics to provide real-time insights for engagement across your intranet.

Site Analytics supports configuration for both Google Analytics 4 and Google Tag Manager.

Note: This guide is for the configuration of Google Analytics 4. For Google Tag Manager instructions, visit Getting started - Google Tag Manager configuration.

Jump to


Google Analytics configuration

Note: Creating a Google GA4 property is a prerequisite to the following steps.

Custom dimensions

Configuring the below custom dimensions in Google Analytics will allow you to filter and view page hits by SharePoint-specific values, i.e., hub site name and URL, plus site name and URL.

  1. Log into your Google Analytics account and go to the Admin screen for the account.
  2. In the Data display section, select Custom definitions and then Custom dimensions
  3. Create the following Custom dimensions:

Dimension name

Scope

Event parameter

Hub Site Name

Event

hub_site_name

Hub Site URL

Event

hub_site_url

Site Name

Event

site_name

Site URL

Event

site_url

Once created the custom dimensions screen should match the screenshot below:

Data retention

Tip: Data retention settings can be adjusted accordingly, however, our recommendation is to use the default data retention settings.

For GA4 properties, retention of user-level data can be set to a maximum of 14 months.

For all other event data, you can choose the length of retention of either 2 or 14 months. You may wish to alter the retention period – further details on data retention can be found here.


SharePoint configuration

Note: only a user with the SharePoint Administrator role can set up this type of alert due to properties that need to be set in SharePoint.

  1. Navigate to a site where the Site Analytics app has been added.
  2. Click the Settings icon on the SharePoint suite bar and navigate to Site contents.
  3. In Site contents, a configuration panel for the Site Analytics extension will appear at the foot of the page. Click on Configure button
  4. A property pane will appear, allowing you to connect the Site Analytics app to your GA4 property.

    You will need to insert a JSON string in the pre-defined format below, replacing the bold item with the GA4 measurement ID.

    JSON format
    [
        {
            "provider": "google",
            "type": "GA4",
            "configuration": {
                "default": {
                    "trackingId": "[insert Google Analytics 4 Measurement ID]"
                }
            }
        }
    ]
  5. Your JSON will be validated to ensure it is correctly formatted. Click on the Save button to apply the SharePoint properties for Site Analytics.

Other SharePoint configuration options

Note: the following configurations are optional.


Using the Overrides feature for multiple GA4 properties

Replace the bold items in the JSON below for different GA4 properties to be configured for different SharePoint sites using the overrides feature.

JSON format
[
    {
        "provider": "google",
        "type": "GA4",
        "configuration": {
            "default": {
                "trackingId": "[insert Google Analytics 4 Measurement ID]"
             },
            "overrides": [
                {
                    "sites": ["/sites/sitename1", "/sites/sitename2"],
                    "trackingId": "[insert Google Analytics 4 Measurement ID]"
                }
            ]
        }
    }
]

 

Disabling the User-ID feature

The User-ID feature in Google Analytics associates a persistent ID for a single user across multiple sessions or devices. In SharePoint terms, this means a more accurate recording in Google Analytics of unique users. In GA4 the User-ID feature is enabled by default.

Note: the actual user identity is deliberately encoded so it is not possible to track individually named users within Google Analytics.

If you do not wish to use the User-ID feature it is necessary to update both the GA4 property reporting identity and configuration in the Site Analytics app.

  1. Log into your Google Analytics account and go to the Admin screen for the account.
  2. In the Data display section, select Reporting identity.
  3. Select Show all and use the Device-based option to disable the User-ID feature.
  4. Replace the bold items in the JSON below to connect the Site Analytics app to a single GA4 property. Data will be sent to this property from wherever the Site Analytics app is enabled, however, the User-ID data will not be sent.

JSON format

[
    {
        "provider": "google",
        "type": "GA4",
        "configuration": {
            "default": {
                "trackingId": "[insert Google Analytics 4 Measurement ID]",
                "enable_user_id": false
            }
        }
    }
]