Track all the things with Google Analytics
Track all the things with Google Analytics
Language
English
Track all the things with Google Analytics
Custom dimensions and metrics allow to track almost anything you could need.
Tue, 2016-03-15 11:15By salva
Certainly, there's no need to introduce Google Analytics as an analytics tool for websites. However, not all of its features are equally known to site administrators, and it's very easy for organisations to get tempted to spend part of their budget into a custom tracking system that covers very specific aspects of their site.
The reality is, though, that Google Analytics can cover much more ground than it seems to, yet some of its features are sometimes overlooked and not really used. We've talked about custom event tracking in the past, and in this post I'd like to introduce another feature introduced not so long ago: custom dimensions and metrics.
Custom dimensions and metrics
At its core, Google Analytics (GA) tracks plenty of details about the visitors of a website. However, the information it tracks can't go beyond the details that can be extracted from the HTTP request or from the user's browser (user location, user browser, language of the user, etc). Anything that falls beyond this type of information belongs to the business domain, and as such, Google Analytics can't really track it without further details
For example, a site owner might want to know how many users like different types of food (vegetables, fish, meat, etc). That's simple enough to track on any site. But now imagine the owner wants to know how well a section of the site is doing with a particular audience (e.g: how popular the "Vegetables" section is among the users that like meat), in order to change their marketing approach, ads displayed on that section, etc, as they want to attract more people from a specific audience. The problem starts to unfold and become more complex now, because in order to surface that information, the site would need to track each visit to a page, but also store information about the specific details of the user that visited that page.
This kind of data belongs to the business domain, and it's exactly what custom dimensions and metrics allow site owners to track. In short, they make it possible to track user information alongside the standard details that Google stores for any page view. So, continuing with the example above, using this feature from GA we can easily track user-specific details, or other details about the contents, (e.g: the food shop that sponsors a specific page). With these details stored, GA allows to surface them when creating custom reports, in the same way we can use the default dimensions and metrics (like language, number of page views, number of sessions, etc).
The bare minimum thing to understand about this feature, is that using a custom metric, we can only track numeric values, whereas using a custom dimension, you can track any type of value (e.g: shop names). This is a basic description of custom dimensions and metrics, but you can find the complete documentation (with guidelines and examples of use case scenarios) in the help section of GA. Now, let's look at how easy it is to set this up in GA and integrate it in Drupal.
Setting up Custom Dimensions and Metrics in Analytics
This step couldn't be much simpler. All you have to do is going to the Administration tab of your GA account, choose the web property for which you want to track some custom data, and expand the Custom definitions section. From there, you can click to add either a custom dimension or a custom metric. For both of them, there are a few additional details to specify. Most of the time the default values will be good to go. For more complex data tracking, refer to the full documentation. The screenshot below shows how to access these pages from the Administration tab. Some more details can be found here.
Setting up Drupal
Once the GA part is sorted out, it's the time to start sending custom information from Drupal. Fortunately, the Google Analytics module already has support for this feature. From the settings page, located at admin/config/system/googleanalytics, you can access two separate fieldsets from which to specify the site or user data to send to Analytics, alongside the page view information. The great thing here, is that it leverages the use of tokens, so every available token in the system can be used here. What if you want to send some custom information that is not provided by an existing token? In such case, Token API comes to the rescue!
The picture below shows the configuration page for the Google Analytics module, with some custom dimensions added as tokens:
Note that I've stayed away of showing any code snippets. If you're not using the Google Analytics module, you can still send custom information to Google very easily, by manually adding the analytics.js file to your site, and with just a few lines of code. Since that's out of the scope of this article, I'll just link to this help page, which shows some examples of code snippets for different scenarios.
Show me the reports
So, we've configured our Analytics account, and configured Drupal to start sending those valuable bits of data that will allow us to engage with our audience in the most efficient way. Now we want to surface this data in some way (tables, anyone?). For that, we just need to go to the Customisation tab (back in the GA interface), and click on create custom report. You'll see there's a section for dimensions, and another one for metrics. Choose the ones to show in the table from your custom ones (or from the standard ones), and save:
After some time (give it at least one day!) the statistics should start to come through, and you'll be able to export, filter, reorder or perform any of the standard operations available in Google Analytics. The screenshot below shows some custom details captured from one of our sites and surfaced through the Analytics UI:
This article is a brief introduction to GA Custom Dimensions and Metrics, and to show how easy is to harness the power of this feature to create complex reports without having to go through a lot of development in your site. While GA is not limitless, it certainly allows for much more than what it's commonly known. Make sure you check it out before discarding it for a custom reports solution.
BlogGoogle Analytics Custom Events
BlogBetter UX in your forms, the easy way