Skip to content

joshwilsonnc/ga_cdm

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

39 Commits
 
 
 
 
 
 

Repository files navigation

A custom implementation of Google Analytics for CONTENTdm 6 users that enables recording metadata field values as GA events

Updated September 2014: set Version to 2.0 - improved jQuery integration for better cross-browser compatibility. It is very important to upgrade to this version to ensure events are tracked across all browsers. Previous code versions have been discovered to miss data in some browsers for recent versions of CONTENTdm.

About

This code evolved from our interest in tracking pageviews of specific items in our digital collections. We wanted a useful way to record metadata field values as part of the data. For example, in our state publications collections, we utilize an "Agency-Current" field which contains the name of the state agency that published the item. This code enables us to specify which fields we wanted to track, and they are recorded as events.

Metadata in CONTENTdm

In this example, if I was tracking the "Agency-Current" field, when an item with that field was viewed, an event would be recorded:

How metadata is recorded in Google Analytics

By default, the event category will be "Pageview by metadata field". The field name will be recorded as the event action, and the field value as the event label.

analytics.js (universal analytics)

To configure, edit the analyticsjs_cdm.js file

  • Ensure that analytics is enabled in CONTENTdm's Website Configuration Tool
  • Add the metadata field names you want to record usage of in the trackTheseFields array
ga.js (classic analytics)

To configure, edit the ga_cdm.js file

  • Add the metadata field names you want to record usage of in the trackTheseFields array
  • Edit gaAccount so that it contains your GA account number
  • Edit digitalCollectionsDomain so that it contains your site's domain
  • Optionally edit hostedAliasDomain if you have a hosted instance URL

About

Custom implementation of Google Analytics for CONTENTdm 6 that enables tracking metadata fields as GA events

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published