Mugo Web main content.

Tracking individual users in Google Analytics

By: Thiago Campos Viana | January 27, 2015 | Business solutions, Web solutions, and google analytics

Google Analytics is the most popular tool for understanding how people are finding and using your site. In addition to its standard reports, you can use its User ID feature to get more fine-grained reporting about registered users. This enables you to better measure, anticipate, and meet or exceed your users' needs.

Google Analytics reports help you discover where your users are coming from, the most viewed pages, access patterns, device usage, display resolution, visitor locations, conversions, and much more. The User ID tracking feature enhances all of those reports but for individual users.

Is your website accessible to people with disabilities?

Get our beginner's guide to website accessibility

Download your FREE copy

There a lot of possible applications for user-specific reporting; for example:

  • An e-commerce site could track what products have been viewed by a certain user and use that information to offer targeted deals that will ultimately lead to more sales.
  • A news portal could analyze the topics a user is interested in and showcase more relevant content and features in order to gain and retain more subscribers.
  • An intranet site could improve company processes by analyzing specific user journeys.
  • A training portal could offer tailored help to individual users.
  • A research website could identify new packages of content that can be sold at a high volume and/or to high value clients.

How to set up Google Analytics User ID reporting

Once you have a Google Analytics account up and running, log in to the web interface and click on the "Admin" link:

Google Analytics account admin link

Google Analytics account admin link

Enable the Google Analytics User ID tracking feature by expanding the "Tracking info" property and then clicking on "User-ID".

Google Analytics tracking info and user id links

Google Analytics tracking info and user id links

On the next page you can enable the feature and create a User-ID view. This view will show only data from registered users.

Activating Google Analytics User-ID

Activating Google Analytics User-ID

Then, you can create a Google Analytics Custom Dimension that will track the user ID.

Adding custom dimensions to Google Analytics

Adding custom dimensions to Google Analytics

You can name your custom dimension "userId" or another relevant identifier. If you have configured everything correctly, you should be able to filter and drill down based on this new dimension in your Google Analytics reports.

Visualing User-IDs in Google Analytics

Visualing User-IDs in Google Analytics

You can also use the advanced filter feature and filter by a specific user ID:

Filtering Google Analytics results by a specific User-ID

Filtering Google Analytics results by a specific User-ID

Of course, you need to configure your website to send the user ID information to Google Analytics. In the eZ Publish content management system, we can do that using the following piece of code somewhere in the pagelayout:

<script>
{literal}
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function()
{ (i[r].q=i[r].q||[]).push(arguments)}

,i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
{/literal}
{if $current_user.is_logged_in}
    ga('create', '{ezini('Google', 'Analytics')}', {ldelim} 'userId': '{$current_user.contentobject_id}' {rdelim});
    ga('set', 'dimension1', '{$current_user.contentobject_id}' );
{else}
    ga('create', '{ezini('Google', 'Analytics')}', 'auto');
{/if}

ga('send', 'pageview');
</script>