Google Universal Analytics For Offline Behavior

I have been a very assiduous visitor to the Weizmann Institute of Science in the last four years as my wife studied her PhD. Besides going through the Institute during week days on my way to work, I also visit the various green areas and playgrounds with my kids during the weekends.

One of the rules that always impressed me in the Institute is that you can’t go in or out without either passing an ID card in a turnstile or driving a registered car. This is a very strict policy, which is similar to a website that requires a login for opening it.

During all my visits to the Institute I never really thought about it using my Web Analyst hat, but this changed last week. While passing my ID card to visit the Institute, it suddenly came to my mind a demo of Universal Analytics by Nick Mihailovski, Senior Developer Programs Engineer in the Google Analytics team, where he showed how it can be used to collect offline data for things like swiping an ID card.

So I thought: “the Weizmann Institute could do some pretty interesting analyses if they used Google Analytics to track offline behavior…” This article shows how I would approach such an implementation. I focus more on the Google Analytics account design, rather than the codes necessary to make it happen; I will provide links to relevant code explanations whenever necessary.

But before that, let’s go over a quick overview of what exactly is Universal Analytics and why is it different from the Google Analytics everyone is acquainted with.

What Is Universal Analytics?

Universal Analytics (UA) is the new generation when it comes to measurement. It is a new way of collecting data with Google Analytics that enables a myriad of capabilities using this platform. Here are some of the highlights:

  • User level data: probably the most significant change from the standard Google Analytics to Universal is that it will no longer aggregate data on a visit level, but on a visitor level. While it is still forbidden to send Personal Identifiable Information to Google Analytics servers, this will enable tracking user level behavior using a unique identifier.
  • Multi environment tracking: with the Measurement Protocol, Google introduced a multitude of additional collection capabilities, allowing its users to collect and send incoming data from any digital device to Google Analytics. This means that we can track more than just websites now, which will be the focus of this article.
  • Custom dimensions & custom metrics: custom dimensions and custom metrics are default dimensions and metrics that can be created to your own specific needs and using information you collect on the website (e.g. information provided by visitors on a registration form).
  • Simplified configuration: Universal Analytics provides more capabilities to change your data collection from within the admin interface, changes that were previously accessible only through the development environment.

There is more to Universal Analytics than the highlights above, you can find a great overview of them in Justin Cutroni’s post, he provides some interesting explanations and examples. And if you are wondering how to go about migrating your current Google Analytics account from the standard code (ga.js) to Universal (analytics.js), here is another useful resource by Justin. Hint: you should do that using the excellent Google Tag Manager.

Another useful resource to learn about Universal Analytics on a more strategic level is Feras Alhlou’s article, where he discusses the extremely valuable new approach of user-centric analytics; this approach can tell us a lot about our visitors. But, it can go beyond that to tell us more in-depth information about their visits and their habits. It essentially gives us an overview of their behavior, which in turn, provides us with a better understanding of our customers.

Google Analytics Account Design – Translating Offline Actions

So, let’s go back to our example, monitoring the traffic/behavior of people going in and out of a closed establishment. The emphasis on “closed” is important, as it enables a much more accurate tracking; the model proposed below would not be possible on a place where people can go in and out unidentified, like a regular store (you will understand why later).

When you set sail for a Google Analytics implementation to track offline behavior, you will be boarding an adventurous ship!

Defining the implementation objective

The first step, as always, should be to define the objective of such an implementation. Here are the three main insights I would like to learn if I worked at the Weizmann Institute:

  1. Flow Visualization: which of the 10+ gates people use the most, and do they come in by car or walking? Do they leave through the same gate or through another gate? This information can be used to plan opening hours of specific gates and whether some gates should be shut down or created.
  2. Rush Hours: which days of the week and time of the day the Institute has the highest number of people inside? This information can be used to plan maintenance works and events.
  3. Facilities usage: there are different people coming in (e.g. students, subscribers to the pool, walkers), when each “segment” visit the Institute? This information can be used to understand the flow of different people through the campus and make changes to streets or pavements.

Visitors, Visits, Devices, Pages, Custom Dimensions

With the goals in mind we can start to define which Google Analytics fields we will use to collect the necessary data. After some thinking, here is how I would like to collect the data:

  • Visitor: when a person gets an ID card (which must always be the first action), he or she will become a new visitor, and will be counted as a unique visitor in future visits to the Institute.
  • Visit: every time a visitor enters the Institute they start a new visit, which will last until the person leaves it.
  • Device: since we don’t have a browser, we consider a device to be the transportation mode, i.e. a car, a motorcycle or legs.
  • Custom Dimensions: in order to segment the visitors and learn more about their behavior, we will create a series of custom dimensions (visitor level) for each visitor:
    • ID: ID number
    • Type: Masters_Student, PhD_Student, Professor, Employee, Spouse…
    • Department: Physics, Biology, Chemistry…
    • Building: the name of the building.
  • Pages: every time a person passes his/her ID card either in a turnstile or drives a car into the Institute we will send a page with the gate name, something in the lines of ‘/walk/main-gate/’. At nights and weekends, a card is also necessary to enter a building, so we will also send a pageview to gather more accurate flow navigation information. Note: I decided to include the transportation mode in the page name as it is an intrinsic characteristic of the gate.
  • Events: we should use events for less “important” actions, things like swiping the card in a photocopier or other in-building activity.

This is basically what I would send to Google Analytics. The resulting information wouldn’t be as rich as in a website, but it would be actionable and organized.

The important is to collect the data you need to help you make decisions, not to collect as much data as possible.

Implementing Google Analytics Offline With The Measurement Protocol

But how do you go about implementing such a thing? That’s not simple, and it will require quite a bit of development. If you work for the Weizmann Institute, the specifications are half done, but if not (which I guess is probably true), you have to first define the objectives and try to map your offline actions into Google Analytics fields (as I did above).

Then, check the Measurement Protocol Developer Guide, it provides and overview and some examples on how to send hits to Google Analytics using the Measurement Protocol.

Then, visit the Measurement Protocol Reference, which describes to where and how to send data to Google Analytics; it also describes the required values when you send data and the supported data types.

Closing Thoughts

In summary, Universal Analytics opens up so many new possibilities! As you can see above, it can be used to anything we can imagine.

But the example above is an exception, very few establishments require identification, and usually you would like to track online and offline behavior. Things like:

  • How successful was an incentive to visit a brick-and-mortar store on the website?
  • How did people that ended up buying a product offline using a coupon got to my website?
  • How many of my AdWords leads ended up closing a deal on a call center?

The list could go on and on, so I hope you enjoy the Analytics journey, it will never end!

Related Posts