A division of Libraries and Academic Innovation

Gelman Hours for GWorld Holders
TODAY Tuesday Tomorrow Wednesday Thursday Friday Saturday Sunday Monday
24 hours 24 hours 24 hours 24 hours 24 hours 24 hours 24 hours
Visitor HoursComplete Hours InformationHolidays and Closures
GELMAN: 24 hours
background image of Gelman Library

Aggregate Tracking: GW Libraries Web Traffic

Christian Aldridge (Web Developer GW Libraries)

[UPDATE: we've switched to the newer "Universal Ananlytics" (analytics.js) which I've covered in another post]

GW Libraries maintains an active web presence across a dozen public facing sites. We use Google Analytics to track visitor traffic for each site, an invaluable tool in helping us understand how people use and interact with our websites.

Recently, as we were building tools to track resources across the library (from workstation usage to turnstile numbers) we needed a better way to find totals for ALL of our web traffic. Google offers an API for Analytics, but a simple solution was to instead create a master aggregate Analytics account and use multiple trackers to point all our sites there in addition to their individual Analytics accounts. 

We named the master account GW Libraries Aggregate and then adjusted the script for our sites as follows:

var _gaq = _gaq || [];
// the current Analytics account
['_setAccount', 'UA-XXXXX-1'],
// new aggregated Analytics account
['aggregate._setAccount', 'UA-XXXXX-2'],


(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);

This simple solution, once we roll it out to all of our web apps, will allow us to easily capture aggregate traffic without interfering with the existing Analytics accounts and their wealth of logged data. We also will be able to follow users as they move between our different sites using the Visitor Flow tool.



We created a filter within the aggregate account that includes the full path for content to help distinguish between the individual sites.

The GW Libraries aggregate account we created in Analytics uses an inactive subdomain ("all.libraries.gwu.edu").

For our Drupal sites that use the Analytics module we dropped the var _gaq definition into the "Code snippet (after)" field of the advanced settings:

var _gaq = _gaq || []; _gaq.push( ['aggregate._setAccount', 'UA-XXXXX-2'], ['aggregate._trackPageview'] );


A more detailed look at implementation and Analytics can be found at jensbits: http://www.jensbits.com/2012/03/28/tracking-multiple-domains-individually-and-as-a-group-in-google-analytics/ 

button: tap to share this content with social media tools
Mobile | Desktop