Page History
Table of Contents |
---|
Google Analytics
...
Support
It is possible to record User Interface traffic by enabling the recording of Google Analytics data within DSpace using the DSpace. DSpace supports either Universal Analytics or Google Analytics 4. Also, under GA4 it currently supports the Google Tag (gtag.js), but not Google Tag Manager (GTM).
Enabling Google Analytics
By default, Google Analytics is disabled in DSpace. To enable it, simply set the value of google.analytics.key
in the DSpace configuration file either your local.cfg or dspace.cfg. Until DSpace version 5.0 only User Interface activity could be recorded, that is to say that downloads initiated straight from a Google search (or any other search engine) were not recorded. As of DSpace version 5.0 downloads are now recorded as Google 'Events', so that all item page views and bitstream downloads are now recorded.
...
:
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 |
Info |
---|
When Google Analytics is disabled, you will see 404 responses returned from the REST API whenever the User Interface attempts to access |
Configuring Google Analytics
Additional configuration are provided to allow for enhanced Google Analytics support.
Property: |
|
Example Value: |
|
Informational Note: | Maximum number of events held in the buffer to send to Google Analytics. Used in conjunction with "cron" settings below. |
Property: |
|
Example Value: |
|
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: |
|
Example Value: |
|
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. 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: |
|
Example Value: |
|
Informational Note: | Which Bundles to include in Bitstream statistics. By default, set to ORIGINAL bundle only. |
Google Analytics Reports in DSpace UI
Warning | ||
---|---|---|
| ||
Google Analytics Reporting is not available in DSpace 7.0. While DSpace 7 can capture statistics via Google Analytics (see above), it is not able to display Google Analytics reports in the DSpace User Interface (like was supported in the XMLUI). It is under discussion as it's unclear how many sites use it. At this time it is tentatively scheduled for discussion as part of 7.2, see used this feature. See DSpace Release 7.0 Status |
...
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 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.
...
.
- Logon to the Google Developers Console https://console.developers.google.com/project with whatever email address you use to access/manage your existing Google Analytics account(s).
- Create a new Google Project. The assumption is that you are developing some new software and will make use of the Google code repository. This is not the case but you need to create the skeleton project before you can proceed to the next step.
- Enable the Analytics API for the project. In the sidebar on the left, expand APIs & auth. Next, click APIs. In the list of APIs, make sure the status is ON for the Analytics API.
- In the sidebar on the left, select Credentials.
- Select OAuth / Create new Client ID, then in the subsequent popup screen select Service account. This will automatically generate the required Service Account email address and certificate.
- Go to your Google Analytics dashboard http://www.google.com/analytics/. Create an account for the newly generated Service Account email address and give it permission to 'Read and Analyze' at account level. See *Note below.
- The generated certificate needs to be placed somewhere that your DSpace application can access and be referenced as described below in the configuration section..
*Note:- The Google documentation specifies that the Service Account email address should only require 'Read and Analyze' permission. However, it would appear this may not be the case and it may be necessary to grant greater permissions, at least initially.
Configuration settings for Google Analytics Statistics
In the [dspace.dir]/config/modules/google-analytics.cfg
file review the following fields. These should be either edited directly or overridden in your local.cfg config file (see Configuration Reference).
...