User ID vs. Client ID or why Google Analytics data is not entirely correct?.

 Blogs
User ID vs. Client ID or why Google Analytics data is not entirely correct?

Let’s start this topic by looking at the basic principles of Google Analytics; its building blocks. To organise data in structures, Google Analytics uses 3 simple components: Users, Sessions, and Interactions. These components are related to each other and are in a hierarchy as we can see in the picture below:

Interactions (or hits) are interactions with Google Analytics script. These are Pageviews, Events and Transactions.

A Session is a certain number of Interactions from the same device browser grouped together into one time frame in which they occurred. In the default Google Analytics configuration, the time frame between these interactions for one session is 30 minutes. If no other interaction is done, the session expires after 30 minutes. If another interaction is done after these 30 minutes, a new session starts.

Users are sessions from the same user grouped together. However, it is very important to know the limitations of Google Analytics when defining an User. Without advanced configuration (which is mentioned further in this article), it’s better to define Users as „devices“ (or browsers) because Google Analytics uses cookies. Therefore, it can’t automatically group the different devices from the same user together (e.g. laptop and cellphone).

So, if a user visits a site on which Google Analytics is implemented and leaves it open in the browser without taking action for 30 minutes and then will do another pageview, a new session starts, despite that the visitor never closed the window. This is the first example of incorrect/„broken“ data in GA. 🙂

Products also belong to the GA components, but we will talk about them some other time.

Cookies

Google Analytics uses cookies. A User (device browser) opens a website with implemented Google Analytics script. Then, the script will find out if that device browser already has a Google Analytics cookie. If not, it will insert the cookie into the browser. If yes, it will use the existing cookie and will define to which User this session should be attributed. How? Based on Client ID.

In the picture above you can see what this cookie looks like. Among other things, it contains:

Name: simply the cookie name. Universal Google Analytics uses _ga.

Value: here are the most important values. In case of a Google Analytics cookie, the format as in the picture above is used, we will talk more about this later on.

Domain: domain in which the cookie was inserted and the only domain that can read it.

Path: path where the cookie was inserted. If only /  is shown, the cookie will be present on the whole website. If there is for instance /blog, the cookie will be present only on  pages where /blog is included in the URL.

Expiration: date, when the cookie expires. This date is refreshed at every visit. The default expiration for a Google Analytics cookie is 2 years.

What happens if users delete cookies in the browser?

During the next visit, a new Google Analytics cookie with a new Client ID will be inserted into the browser. So in the Google Analytics report, this browser will be recognized as a new user.

Client ID

Every Google Analytics cookie contains this value (of course, with different numbers). What do these numbers and letters represent?

GA1 – this is static. It’s simply the GA version 1.

2 – if the cookie was inserted in the top level domain .maxlead.com, the number will be 2. If the cookie was inserted just for .subdomain.maxlead.com, the number would be 3. It represents the number of components in the URL, separated by dots.

303899533 – randomly generated number.

1501248220 – the timestamp, when the cookie was inserted. It is the exact number of seconds, passed from the date 1.1.1970. In our case, after „decoding“, it’s: Fri, 28 Jul 2017 15:23:40 +02:00.

These last two numbers together, the random generated number + the timestamp, create the unique Client ID.

So, besides separating the Users in Google Analytics, where else can we use this Client ID? One example is Cross-Domain tracking. Here is how it could be used: site A will after a click out to site B pass its Client ID to the site B. It will happen through URL and Google Analytics on the site B will read this Client ID from URL and attribute this session to the same user on the site B. So, on both sites, in our Analytics reports, it will be one continuous session from the same user with original source of visit.

A few important things to mention: we need to have 1 rollup Google Analytics on both sites and also do some other things to guarantee the proper functionality. We will be writing a step by step guide about Cross-Domain tracking soon.

User ID

Imagine the following situation:

One and the same person comes to your site directly during the first session, then for the second session this person comes from a price comparison site and lastly for the third session from a paid search campaign and converts. How many users will this person represent in Google Analytics?

That was easy – one.

But, what would be the case if the second session was done through a tablet?

 

In this case, there would be 2 users in Google Analytics, despite it being one person. This means we are losing important data from the customer journey for evaluating the investments into the price comparison site.

A similar scenario would be when one person visits the site from the same device, but through different browsers:

By now the above examples show the underlying issue, but how to improve our data? Using the User ID.

In order to use the User ID, you need to have a login system on your webpage where the users can login, followed by little changes to your website source code and Google Analytics. Eventually these little changes will also have to be made in Google Tag Manager (which we will explain further in a next article soon). The results would look like this:

Every time the user logs in on your site, the site will send his unique ID which is tied to his login, to Google Analytics. So, if the user first logs in on your site through a computer and later on a cellphone, in both cases, the same ID will be sent and Google Analytics will recognize this user (devices) and will be able to connect them into one user.

It is important to mention that even after implementing this functionality and user log-in, previous sessions will not be connected. Only those sessions, during which the User ID was present, will be connected. Google Analytics does not work retroactively, so it can not change the past data and connect those sessions together.

After correct implementation of the User ID, you will, for example, be able to see a report, where the device usage for users visiting your website can be shown as below:

You can also see the most common combinations of devices with interesting metrics like these below:

I hope that you liked this article and found it useful. If you did, we would be happy, if you could share it and help also other people.

 

Leave a Reply