← You're reading a post on Code for America's Blog Archive. Head back to our main site.

Toward Unified Digital Analytics: The Philadelphia Way

As part of our Digital Front Door initiative, we’re highlighting great examples of local governments taking data-driven approaches to designing and redesigning their websites. We caught up with Lauren Ancona, a Data Scientist in the City of Philadelphia’s Office of Information and Technology, who played a key role in launching a public, near real-time dashboard that shows traffic to the City of Philadelphia’s webpages using Google Analytics and Google Tag Manager.

analytics

Here’s her story:

When I started at the City in December, the first thing I wanted to see was the Google Analytics account for phila.gov. One of the biggest challenges in getting meaningful data from any analytics tool is considering the source: what does the implementation look like? In our case, the City’s website had gone through numerous iterations in the past several years, parts of which were built by contractors. This meant that we had an analytics account that was reporting on traffic dating back to 2010, but no way to know how much of the site was included in that account, when the snippet may have been added or removed from parts of the site, and even duplicated in others.

Reliable benchmarking would have been nice, but since we really needed to measure current usage and track the impact of upcoming releases, it wasn’t the end of the world. Now we needed to determine how many sites were not yet included in the tracking. I figured we could just start with a list of all city sites and check if we were seeing traffic in Google Analytics…except there was no list.

Factors leading to the fragmented nature of the City’s web properties are outside the scope of this project, but suffice to say it’s not a problem that’s unique to Philadelphia. Offices and departments have a huge spectrum of technological needs, and have had to solve for their use-cases as both time and funding allows. The result is that we had to make our own list, and start reaching out to departmental IT directors to invite participation.

The most difficult part of rolling out a unified analytics program within a government structure with many siloed web properties (including many that aren’t part of the primary .gov domain) is managing deployment. For this, we turned to Google Tag Manager, a mature product that was developed for and mostly utilized by marketers. It provides a graphic interface to manage advertising tracking beacons: single-pixel images used to count sales conversions, and was designed to seamlessly integrate with Google Analytics.

Example ‘Tags’ in the Google Tag Manager dashboard

However, its true beauty is the ability to (securely) make adjustments to an analytics implementation without direct access to the site’s codebase. Vendor lock in is less of a worry, too; though GTM itself is a Google product, if ever we wanted to move to a different analytics tool, it’s as simple as swapping out the Google Analytics “tag” with the new tool’s tracking snippet…in one place: the Tag Manager dashboard.

An example snippet looks like:

Example snippet

Let me say that again: once the container is installed (it looks similar to the standard Google Analytics snippet), you do not need to touch the code to add data to your reporting configuration, including custom dimensions and metrics. It’s capable of one-to-many management of Google Analytics properties as well, which means we can send reporting to multiple analytics accounts from within a single container, simply by adding a new “tag” (GTM’s name for the equivalent of the analytics snippet). For example, if the agency has its own analytics property, it’s easy to send data to both the agency’s account and the umbrella or “rollup” account you’re using to aggregate government-wide traffic.

Visualization of relationships between tags, triggers, & variables in a Google Tag Manager container

Our toolbox for rolling out Unified Analytics looks like this:

Reporting

Testing

With the exception of Screaming Frog, all of the software used in this project is free, and all code used in the new analytics.phila.gov is open source.

This initial version includes a live count of users, updated each minute, an hourly count of users for the current day, and the top 20 most-visited pages over 3 periods: right now, the past week, and past month.

Want to roll out unified analytics in your city or state?

Check out the City of Philadelphia’s step-by-step guide — starting from scratch — to start a basic “rollup” reporting profile using Google Analytics and Google Tag Manager. They’ll continue building out instruction over the coming months. Learn more about analytics and website redesigns in CfA’s Digital Front Door Resources.