This Confluence wiki site, maintained by DuraSpace prior to the recent merger with LYRASIS, will transition from the duraspace.org domain to the lyrasis.org domain on Saturday, Nov 16 beginning at approximately 7pm ET. A period of downtime of 2-3 hours is expected. After the transition, this wiki will be available at https://wiki.lyrasis.org/. All links to duraspace.org wiki pages will be redirected to the correct lyrasis.org URL. If you have questions prior to or following the transition please contact: wikihelp@lyrasis.org.
Page tree
Skip to end of metadata
Go to start of metadata

Google Analytics Recording

For a number of years now it has been possible to record User Interface traffic by enabling the recording of Google Analytics data within DSpace using the jspui.google.analytics.key or xmlui.google.analytics.key in the DSpace configuration file 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. 

Google Analytics Reporting

As of DSpace version 5.0 it has also become possible to expose that recorded Google Analytics data within DSpace. At present this is only available to those sites using themes based on the XMLUI Mirage2 theme but it is hoped that further development will result in it being available for other XMLUI themes and for the JSPUI. 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.

  1. Enable the Google Analytics XMLUI aspect by editing the configuration file {dspace.dir}/config/xmlui.xconf.
  2. 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).
  3. 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.
  4. 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.
  5. In the sidebar on the left, select Credentials.
  6. 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.
  7. 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.
  8. Download the P12 key file, and place it 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 to this specific Property, it does not need permissions to your Account level Google Analytics.

Configuration settings for Google Analytics Statistics

In the {dspace.dir}/config/modules/google-analytics.cfg file review the following fields to make sure they are uncommented:

 

Property:

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:

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 (i.e. All Web Site Data) 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). This is not the same as your Property Settings Tracking ID (i.e. UA-112233-6)

Account[Longsight DSpace Clients] -> Property[SUNY Dev] -> View[All Web Site Data] -> View Settings

 

Then this value is the View ID:

 

Property:

account.email

Example Value:

xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx@developer.gserviceaccount.com

Informational Note:

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

Property:

certificate.location

Example Value:

/home/myudspace/var/MYU-abc123.p12

Informational Note:

The certificate file automatically generated when you created the Service Account. The credentials site will generate a JSON file, and then separately you have to download a new P12 file. Copy it somewhere to your DSpace server, and set this property to the path.

Property:

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.

 

Once Google Analytics Statistics is enabled and configured, you can then view reports. An example report looks like:

http://localhost:8080/xmlui/handle/999/1/google-stats

 

  • No labels