Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Removed irrelevant UA documentation and modified links for accessiblity.

...

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

...

Property:

google.analytics.buffer.limit

Example Value:

google.analytics.buffer.limit = 256

Informational Note:

Maximum number of events held in the buffer to send to Google Analytics.  Used in conjunction with "cron" settings below.

Property:

google.analytics.cron

Example Value:

google.analytics.cron = 0 0/5 * * * ?

Informational Note:

REQUIRED if you want to send file download events to Google Analytics (where they will be tracked as Google "events").  This defines the schedule for how frequently events tracked on the backend (like file downloads) will be sent to Google Analytics. Syntax is defined at https://www.quartz-scheduler.org/api/2.3.0/org/quartz/CronTrigger.html  

The above example will run this task every 5 minutes (0 0/5 * * * ?)

For Google Analytics 4, you MUST also add the "api-secret" below to support sending download events.

Property:

google.analytics.api-secret

Example Value:

google.analytics.api-secret = mysecret

Informational Note:

(Only used for Google Analytics 4) Defines a Measurement Protocol API Secret to be used to track interactions which occur outside of the user's browser.
This is REQUIRED to track downloads of bitstreams. For more details see https://developers.google.com/analytics/devguides/collection/protocol/ga4 

Steps to create your API secret are also available from https://www.monsterinsights.com/docs/how-to-create-your-measurement-protocol-api-secret-in-ga4/

Property:

google-analytics.bundles

Example Value:

google-analytics.bundles = ORIGINAL

Informational Note:

Which Bundles to include in Bitstream statistics.  By default, set to ORIGINAL bundle only.


Google Analytics Reports in DSpace UI

...

Property:

google-analytics.application.name

Value:

Dummy Project

Informational Note:

Not sure if this property is required but it was in the example code provided by Google. Please do not delete.

Property:

google-analytics.table.id

Example Value:

ga:12345678

Informational Note:

Logon to the Google Analytics Dashboard and select the Property (or website in plain English) that you wish to target. Then select the Admin section for the property. You should then be able to select the 'view settings' for the view you are interested in. The View ID should replace 12345678 below (note - confusingly the Reporting API documentation refers to the View ID as Table ID).

Property:

google-analytics.account.email

Example Value:

xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx@developer.gserviceaccount.com

Informational Note:

The email address automatically generated when you created the Service Account.

Property:

google-analytics.certificate.location

Example Value:

/home/example/dslweb--privatekey.p12

Informational Note:

The certificate file automatically generated when you created the Service Account.

Property:

google-analytics.authorization.admin.usage

Example Value:

true

Informational Note:

Control if the statistics pages should be only shown to authorized users. If enabled, only the administrators for the DSpaceObject will be able to view the statistics. If disabled, anyone with READ permissions on the DSpaceObject will be able to view the statistics.

Google Analytics development and debugging

Identifying outgoing events in Chrome Dev Tools

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

The GA4 Measurement protocol and event parameters

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: GA4 Monitor events in DebugView