All Versions
- DSpace 7.x (Current Release)
- DSpace 8.x (Unreleased)
- DSpace 6.x (EOL)
- DSpace 5.x (EOL)
- More Versions...
Contribute to the DSpace Development Fund
The newly established DSpace Development Fund supports the development of new features prioritized by DSpace Governance. For a list of planned features see the fund wiki page.
It is possible to record User Interface traffic by enabling the recording of Google Analytics data within DSpace. DSpace supports either Universal Analytics or Google Analytics 4.
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:
# For Universal Analytics (older style Google Analytics) google.analytics.key = UA-XXXXXX-X # Or, for Google Analytics 4 google.analytics.key = G-XXXXX
When Google Analytics is disabled, you will see 404 responses returned from the REST API whenever the User Interface attempts to access ${dspace.server.url}/api/config/properties/google.analytics.key
. This is expected behavior, as that 404 response is the REST API telling the User Interface that Google Analytics is not configured. When the UI sees that 404 from the REST API, it disables Google Analytics tracking the UI.
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. |
DSpace 7 does not yet support
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 used this feature. See DSpace Release 7.0 Status
As of DSpace version 5.0 it has also become possible to expose that recorded Google Analytics data within DSpace. The data is retrieved from Google using the Google Analytics Reporting API v3. This feature is disabled by default, to enable it please follow the instructions below.
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.
*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.
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).
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. |