Track Custom Dimensions through Google Analytics

There has been a great discussion about Web Traffic Analytics for All Books reporting at Institutional level that pointed me to the instructions for setting up Google Analytics across our instance of Pressbooks which has been super helpful and we are loving the reports that we are able to get from there.

One missing feature that would make the data much more useful for us to share with others would be the ability to filter by institution. Currently - there is now way in the analytics to programmatically differentiate between books from different institutions across our instance. Google Analytics provides a fairly straight forward way to add custom dimensions that could pull in other information about the book analytics and we can do some of that setup from the admin side of Google Analytics, but it also requires a small snippet of code to be added to the on-page tracking code:

var dimensionValue = 'SOME_DIMENSION_VALUE';
ga('set', 'dimension2', dimensionValue);

I don’t think there needs to be a way for customers to add their own custom dimensions, but I wonder if there are common dimensions that would be helpful for everyone such as:

  • Book name
  • Institution

Those variables are already available on each page and should be fairly straightforward to pull into those variables and then they would be available for users to use in Google Analytics.

Alternatively, if there was an option to use Google Tag Manager - we could add those custom variables on our own.