Docsity

Using Google Tag Manager and Google Analytics to track ..., Summaries of Statistics

Toggle sidebar
bg1
Using Google Tag Manager and Google
Analytics to track DSpace metadata fields
as custom dimensions
DSpace can be problematic for those interested in tracking download and pageview statistics granularly.
Some libraries have implemented code to track events on websites and some have experimented with using
Google Tag Manager to automate event tagging in DSpace. While these approaches make it possible to
track download statistics, granular details such as authors, content types, titles, advisors, and other fields for
which metadata exist are generally not tracked in DSpace or Google Analytics without coding. Moreover, it
can be time consuming to track and assess pageview data and relate that data back to particular metadata
fields. This article will detail the learning process of incorporating custom dimensions for tracking these
detailed fields including trial and error attempts to use the data import function manually in Google
Analytics, to automate the data import using Google APIs, and finally to automate the collection of
dimension data in Google Tag Manager by mimicking SEO practices for capturing meta tags. This specific
case study refers to using Google Tag Manager and Google Analytics with DSpace; however, this method
may also be applied to other types of websites or systems.
by Suzanna Conrad, Digital Initiatives Librarian and Head of Digital Services & Technology, Cal Poly
Pomona
Introduction
Cal Poly Pomona launched an institutional repository, dubbed “Bronco Scholar,” in February 2014 to
support various types of scholarship from the campus community. As one of twenty-three California State
University (CSU) campuses, Cal Poly Pomona was able to use a multi-tenant, shared instance of the open-
source repository software DSpace hosted by the CSU Chancellor’s Office. While we are provided with a
number of helpful statistics about bitstream downloads, searches, and other statistics within this multi-
tenant instance, accessing granular data about specific downloads is a very time-consuming and manual
process. It was important to us to be able to track specific details about individual downloads and
pageviews including author names, advisor names for student research projects, content types, and titles of
items accessed. And, because our DSpace instance is part of a multi-tenant instance and we do not have full
administrator privileges to edit code, we needed a solution that would not require much custom code.
This article will detail the learning process of incorporating custom dimensions for tracking these detailed
fields including trial and error attempts to use the data import function manually in Google Analytics, our
attempts to automate the data import using Google APIs, and finally how we successfully automated
collection of dimension data in Google Tag Manager by mimicking SEO practices for capturing meta tags.
This specific case study demonstrates using Google Tag Manager and Google Analytics with DSpace;
however, this method may also be applied to other types of websites or systems.
Google Analytics & events tracking
Google Analytics is often implemented by libraries of all types to track website usage. A simple snippet of
JavaScript code on a website linked to a Google Analytics account enables Google to intercept page
requests and capture standard data that is sent by a user agent along with the request — such as information
about the requested page and the user agent that’s making the request. With vanilla Google Analytics,
website owners can view a standard set of metrics (such as the number of pageviews or unique pageviews)
grouped by a standard set of dimensions (such as page URL, page title, user location, etc.).
pf3
pf4
pf5
pf8
pf9
pfa
pfd

Partial preview of the text

Download Using Google Tag Manager and Google Analytics to track ... and more Summaries Statistics in PDF only on Docsity!

Using Google Tag Manager and Google

Analytics to track DSpace metadata fields

as custom dimensions

DSpace can be problematic for those interested in tracking download and pageview statistics granularly. Some libraries have implemented code to track events on websites and some have experimented with using Google Tag Manager to automate event tagging in DSpace. While these approaches make it possible to track download statistics, granular details such as authors, content types, titles, advisors, and other fields for which metadata exist are generally not tracked in DSpace or Google Analytics without coding. Moreover, it can be time consuming to track and assess pageview data and relate that data back to particular metadata fields. This article will detail the learning process of incorporating custom dimensions for tracking these detailed fields including trial and error attempts to use the data import function manually in Google Analytics, to automate the data import using Google APIs, and finally to automate the collection of dimension data in Google Tag Manager by mimicking SEO practices for capturing meta tags. This specific case study refers to using Google Tag Manager and Google Analytics with DSpace; however, this method may also be applied to other types of websites or systems.

by Suzanna Conrad, Digital Initiatives Librarian and Head of Digital Services & Technology, Cal Poly Pomona

Introduction

Cal Poly Pomona launched an institutional repository, dubbed “Bronco Scholar,” in February 2014 to support various types of scholarship from the campus community. As one of twenty-three California State University (CSU) campuses, Cal Poly Pomona was able to use a multi-tenant, shared instance of the open- source repository software DSpace hosted by the CSU Chancellor’s Office. While we are provided with a number of helpful statistics about bitstream downloads, searches, and other statistics within this multi- tenant instance, accessing granular data about specific downloads is a very time-consuming and manual process. It was important to us to be able to track specific details about individual downloads and pageviews including author names, advisor names for student research projects, content types, and titles of items accessed. And, because our DSpace instance is part of a multi-tenant instance and we do not have full administrator privileges to edit code, we needed a solution that would not require much custom code.

This article will detail the learning process of incorporating custom dimensions for tracking these detailed fields including trial and error attempts to use the data import function manually in Google Analytics, our attempts to automate the data import using Google APIs, and finally how we successfully automated collection of dimension data in Google Tag Manager by mimicking SEO practices for capturing meta tags. This specific case study demonstrates using Google Tag Manager and Google Analytics with DSpace; however, this method may also be applied to other types of websites or systems.

Google Analytics & events tracking

Google Analytics is often implemented by libraries of all types to track website usage. A simple snippet of JavaScript code on a website linked to a Google Analytics account enables Google to intercept page requests and capture standard data that is sent by a user agent along with the request — such as information about the requested page and the user agent that’s making the request. With vanilla Google Analytics, website owners can view a standard set of metrics (such as the number of pageviews or unique pageviews) grouped by a standard set of dimensions (such as page URL, page title, user location, etc.).

Using custom JavaScript, one can capture additional data about page activity by using event tracking. With event tracking, one can set up JavaScript event handlers to submit data to Google Analytics every time a particular event is triggered (such as when a page element is clicked or a key is pressed). For instance, if one specifically wanted to track downloads of PDFs on a website, one could set a particular Google Analytics event to be recorded each time a relevant download link is clicked. Other authors have discussed technical implementations and benefits of event tracking using JavaScript edits and custom variables.^1 Once event tracking is implemented in Google Analytics, it is possible, for example, to track downloads by file types, file names, and other dimensions. Furthermore, it is possible to set up goals to better track conversions, such as tracking the percentage of users visiting the site who actually download repository content.

Google Analytics custom dimensions & metrics

If website owners want to track certain metrics or group data based on dimensions that are not included in default Google Analytics, they can set up custom metrics or dimensions as discussed in the Google Analytics Platform Principles Course.^2 Within the standard Google Analytics reporting tools it is possible to use custom dimensions as secondary dimensions when viewing reports. In our case, we were specifically interested in grouping data based on a key set of metadata tracked in DSpace: content type, author name, advisor name, and title. Adding these metadata fields as custom dimensions was a logical way to accomplish this goal.^3

Google Tag Manager

Google Tag Manager is a product that provides a simplified means of updating website “tags.” By Google’s definition, “a tag is a snippet of JavaScript that sends information to a third party,” such as a piece of custom Google Analytics event tracking code.^4 Coates and Durrant discussed the usage of Google Tag Manager to track events specifically within DSpace.^5 However, these principles can apply to all types of websites that need to track events. As long as a code snippet for Google Tag Manager can be implemented on the website, it is possible to automate tag creation without editing the code on each and every page.

For example, many event tracking implementations include sample code such as:

Download PDF

In Google Tag Manager this function can be handled by a tag. The tag fires on a page according to the rules established for that tag.

(^1) Wilson, J. (2014). Personalize Your Google Analytics Data with Custom Events and Variables. Code4lib.

http://code4lib.org/files/Wilson-c4l14.pdf; Farney, T., & McHale, N. (2013). Event tracking: Getting all your data. Library Technology Reports, 49(4), 27. (^2) Google Analytics Academy: Google Analytics Platform Principles. (n.d.)

https://analyticsacademy.withgoogle.com/course (^3) Note that you must use Universal Analytics in order to create custom dimensions and metrics. Classic

Google Analytics uses custom variables, instead. (^4) Tag Manager Help: About Google Tag Manager. (n.d.)

https://support.google.com/tagmanager/answer/2574305?hl=en (^5) Coates, H. & Durrant, S. (2013). Improving user engagement in a data repository with web analytics.

LITA Annual Forum. http://connect.ala.org/files/Durrant%26Coates_2013_LITAForum_DataRepoWebAnalytics_0.pdf

point for attempting to implement custom dimensions. To test this data import function, we first set up four custom dimensions in Google Analytics using custom definitions in the Property Admin section:

Figure 2: Custom dimensions admin setup in Google Analytics

Then we set up these dimensions in the data import section (also located under Property Admin in Google Analytics), which provided us with the keys to map each of the metadata fields to a dimension, e.g., ga:dimension3 maps to the “advisor” custom dimension.

Figure 3: Mapped metadata fields in Google Analytics data import

DSpace does offer a metadata export function, which we used to get a metadata dump for the CSV file. This file was unfortunately very messy; often the metadata fields would span two columns so we had to combine those fields manually. Also quotations within titles were corrupted during the export and some fields had to be normalized before they could be imported successfully to Google Analytics. We were only

interested in tracking four metadata fields in custom dimensions, so we also had to reduce the CSV to include only those four columns and the unique key that Google Analytics would reference to assign dimensions to pages. In our case, the unique key was the pagePath, which corresponded to the handle URL in DSpace. Our final CSV included columns for the pagePath and four columns for the custom dimensions as defined in Google Analytics.

Figure 4: Sample CSV file for Google Analytics data import

Once we had cleaned up the CSV file and set the paths and dimensions to correspond to the custom dimensions in Google Analytics, we were able to upload the CSV under the “Data Import” section under Property Admin. This process was successful and we were able to see the custom dimensions in our reports.

Figure 5: Custom dimensions displaying in Google Analytics (data import)

There were a number of disadvantages to this method. Dimension widening is not retroactive, so the dimensions applied only to downloads and pageviews occurring after the data import had happened. The manual process of cleaning the CSV was also extremely time-consuming, and a more automated process would ensure that all downloads and pageviews could be captured. Within the Platform Principles course, the Google Analytics Academy also mentions APIs for dimension widening, so we began to investigate how we could automate this process using the APIs instead.

We tested scraping the site and dumping the correct metadata fields into a CSV that could be pulled into Google Analytics using the APIs. We were able to get a cleaner data pull of the metadata fields than with the DSpace metadata export. However, two problems still existed. First, a process still had to run to pull the data into Google Analytics using the APIs, and second, the dimensions would only be recorded as of the time that process ran, which meant that usage statistics of new uploads would not be tracked immediately after upload.

Since Google Tag Manager was already firing on our DSpace instance pages, we began investigating the possibility of using existing tags to track metadata fields and include those fields as custom dimensions. One SEO blogger discussed the possibility of tracking meta tag values using Google Tag Manager to determine what optimized keywords were performing best on individual webpages.^8 DSpace includes metadata fields as meta tags in the page source, so this solution offered automated tracking of DSpace item- level metadata using custom dimensions.

(^8) Moore, A. (2013). SEO reporting with Google Tag Manager.

http://www.lunametrics.com/blog/2013/12/30/seo-reporting-google-tag-manager/#sr=g&m=o&cp=or&ct=- tmc&st=%28opu%20qspwjefe%29&ts=

This cycles through the page when the tag is fired and looks for multiple DC.creator meta tag elements on the page (to account for multiple authors). All custom JavaScript in Google Tag Manager macros must include a return statement, so the return statement here returns the text of the meta tag elements.

Once the additional macros were enabled, it was simple to add the custom dimensions to the existing tags we had created in Google Tag Manager using the index number we set up in Google Analytics Custom Dimensions.

Figure 7: Mapping custom dimensions in Google Tag Manager

After this was set up, we were able to add secondary dimensions to reports using the custom dimensions in Google Analytics.

Figure 8: Custom dimensions as secondary dimensions in Google Analytics (Downloads)

In order to track conversions, we also added a pageview tag that referenced the same two macros. Again, we designated the custom dimensions with the correct index number from Google Analytics.

Figure 10: Custom dimensions as secondary dimensions in Google Analytics (Pageviews)

Our final implementation to track custom dimensions on downloads and pageviews included the following tags:

Figure 11: Complete setup in Google Tag Manager

Meta tag challenges with DSpace

While setting up the custom macro to find the meta tag elements, we noticed some inconsistencies in the way that DSpace produces meta tags. Specifically, many of the Qualified Dublin Core metadata fields we entered displayed as other meta tag fields. For instance, dc.contributor.advisor and any other dc.contributor fields besides dc.contributor.author would appear as dc.contributor metatags without the additional qualifier. The dc.contributor.author fields appeared as dc.creator meta tags. Figures 12 and 13 illustrate these discrepancies.

Figure 12: Metadata fields in Qualified Dublin Core from DSpace full record view

Figure 13: Meta tag fields in the DSpace page source view

While this was not ideal, especially in instances where we were using metadata fields such as dc.contributor.department and dc.contributor.other, we were still able to return the text of the fields we were interested in displaying in Google Analytics using the Google Tag Manager custom JavaScript macro. When multiple values are found for these metadata fields in our current configuration, all values found populate the Google Analytics reports with pipes (“|”) between the text from each meta tag. As a result, because multiple different meta tag fields might get collapsed into the same custom dimension, we have to make sure we account for these special cases (such as our dc.contributor.department fields appearing along with advisor names) when looking at reports.

Alfredo Lafarga for testing and trying various solutions. Thanks to Summer Durrant for her advice on getting download tags to work and for alerting us of Google Tag Manager through her 2013 LITA Forum presentation. Also, thanks to the STEP Program Grant at Cal Poly Pomona for funding the launch of the repository and the Office of Undergraduate Research for their efforts in its continued success.