Universal Analytics and Drupal - What do you need to know?

Rick Donohoe's picture
May 15th 2014Account Manager

Universal Analytics is the latest improvement to Google Analytics and primarily aims to provide a more user-centric view so you can see how users are engaging with your website across a wide range of different devices. This post aims to cover some of the key areas such as why you should upgrade and how to upgrade.

Universal Vs Classic

New members are automatically signed up to Universal, with existing members being offered the choice to upgrade at their own will. Google will however automatically move all members over at some point soon. 

Universal Analytics offers the same features and services as the classic Google Analytics, but offers a number of additional features which you may find useful.

What new features can I make use of?

User ID feature

Universal Analytics can receive data in relation to a specific User ID, which means you can now track multiple sessions for a single user over different devices with a persistent ID.  For example, a user may have registered on your site during the day using their phone then returned later that evening to make a purchase using their desktop PC. It’s now possible to view this kind of cross device and cross session user engagement.

New and more flexible data collection methods

Three new data collection methods are introduced with Universal Analytics, which means you can now track behavior on any digital device rather than just websites. Apps, game consoles and information kiosks for example can now all be tracked!

Timezone based processing

Google Analytics previously processed data in Pacific Standard Time, but with Universal Analytics data is now processed based on the timezone set in your specific view.

Organic search sources

Analytics recognises traffic from popular search engines as organic search traffic and attributes all other directed traffic as referred traffic. You can now modify the list of search engines to control how Analytics displays traffic from search engines which aren’t on its list.

Referral and Search exclusions

You can now exclude specific websites from being listed within referred traffic, and exclude specific terms from being listed within organic search traffic.

Common use cases for this maybe where you want to discount customers who found you by searching for your company/brand name from organic search traffic, or to discount URLs from referred traffic which are a third party service of your website (such as a redirect as part of a commerce workflow).

Session and campaign timeout handling

Universal Analytics allows you to manually set session and campaign durations to make them more applicable to the business requirements of your website.

What do I need to do to upgrade to Universal Analytics?

To upgrade to the new Universal Analytics you must upgrade your GA property first via the admin section in your Google account. You must have the edit permission assigned to your account to do this, and the transfer should take between 1 and 2 days to fully complete.

There are a number of things to consider before you upgrade, so see if any of them apply to you first.

Once the GA property has been upgraded you will need to update your website tracking code, however this step is optional and not doing so will only prevent you from utilising the new features, as all existing features will still work correctly.

Note: You must upgrade the property first, as upgrading the code before upgrading the property will cause data to no longer be tracked.

Updating the Drupal tracking code

At the time of writing there are 2 different versions of the Drupal 7 Google Analytics module; 7.x-1.4 and 7.x-2.x-dev.

The 7.x-1.4 branch is the current stable release which has been available for a number of years and uses the standard Google Analytics (GA.js support).

The 7.x-2.x-dev branch is the new development version to support the new Universal Analytics, and is currently unstable. Further information is provided by hass (the modules primary maintainer) as follows:

This branch is not yet fully functional and removes a lot of well known features like:

  • AdSense (Not yet available)

Known to be broken:

  • Custom Variables are now custom dimensions/metrics and not yet implemented.

However others have reported that the upgrading to the new module appeared to be seamless.

It should be noted that if you use both the old ga.js script and the new analytics.js script together then pageviews will be over-counted in reports, therefore the updated script should replace the old script.

If you wish to use the new script but do not want to upgrade to the new 7.x-2.x-dev branch then I would recommend disabling the Google Analytics module and adding the new script to the head of your html.tpl.php file, which as pointed out by John Downing at Drupal Camp Ottowa  is fine in practice, but not preferred as support provided by the module is ideal and offers additional functionality such as custom reporting.

Additional tracking code syntax changes

Other syntax changes have been made which may require code to be updated such as changes to how events and ecommerce are tracked.

Here at Microserve we often add custom events tracking code to track clicks on menus and promotional items to enable us to see which content the user is most interested in, which means we would need to also manually change the JS code for any sites we upgrade.

Codewise, events were previously tracked with a code snippet like this:

gaq.push(['_trackEvent', 'category', 'action', 'opt_label', opt_value, opt_noninteraction]);

however the new tracking code requires them to be tracked like this:

ga('send', 'event', 'category', 'action', 'opt_label', opt_value, {'nonInteraction': 1});

A full list of tracking code changes can be found here.

How does this affect me and do I need to act now?

The most important thing we would recommend is to not blindly update to Universal Analytics before consulting your developer(s), as you need to be sure that the changes will not negatively impact your site.

True, reporting will still work without any code changes needed, but are there any custom variables or snippets which your site uses that the new Universal Analytics is no longer compatible with?

We would also recommend you don’t completely ignore the update, as it's much better to upgrade painlessly or be prepared to upgrade when required, rather than waiting for Google to automatically upgrade your site to Universal Analytics for you.

Microserve's picture

You may also like...

New Module: Block and Unpublish

Microserve, Feb 26th 2014
As an agency we get to work on a wide range of projects, each with its own requirements for solutions and features. On occasion we find ourselves...

Add new comment

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.

Related Blogs

Sophie Shanahan-Kluth's picture
Rick Donohoe's picture
Mark Pavlitski's picture