Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Deleted now irrelevant UA instructions and added some links for GA4 support

...

It is possible to record User Interface traffic by enabling the recording of Google Analytics data within DSpace.   DSpace supports either Universal Analytics or supports Google Analytics 4 and as of July 1, 2024, Google Analytics 4 has replaced Universal Analytics. Also Also, under GA4 it currently supports the Google Tag (gtag.js), but not Google Tag Manager (GTM). See Where is My Google Tag ID for more information. 

Enabling Google Analytics

By default, Google Analytics is disabled in DSpace.  To enable it, simply set the value of google.analytics.key in either your local.cfg or dspace.cfg:

Code Block
# For Universal Analytics (older style Google Analytics)
google.analytics.key = UA-XXXXXX-X

# Or, for Google Analytics 4
google.analytics.key = G-XXXXX

...

Please read the documentation found at  https://developers.google.com/analytics/devguides/reporting/core/v3/  and https://developers.google.com/accounts/docs/OAuth2ServiceAccount. It is the definitive documentation, however, it is over detailed for our purposes so the critical steps are summarised summarized below. The theory is that as a developer you would create a Google project, write your application and store the code in the Google code repository, then create a Google Service Account which your application could use to retrieve data from the Google Analytics API. In our case we already have our application, DSpace, but we still have to go through the motions of creating a project in order to be able to be able to generate the Service Account which we need to allow DSpace to talk to the Google Analytics API.

...

Through "Inspect Element" in Chrome dev toolsDevTools, you can identify outgoing requests to Google Analytics filtering on requests starting with "collect?"

The GA4 Measurement protocol and event parameters

https://www.thyngster.com/ga4-measurement-protocol-cheatsheet/ Google Analytics 4 Measurement Protocol provides a handy overview of the parameters that are sent along.

Analytics Debug View and Debugger Chrome extension

DebugView documentation: https://support.google.com/analytics/answer/7201382?hl=en  GA4 Monitor events in DebugView