Humanlytics

View Original

How and why you should be using User Segmentation in Google Analytics

Who are all these people on my website and how do I categorize them?

Last week, we made a step by step guide for you on how to create your first Google Analytics API request in Python, and submit it using the Google API client library.

It’s a pretty solid first read before this and c couple of coming articles. If you missed it, you can find it at the link below: Submitting your first Google Analytics Reporting API Request

Today, we are going back to finalizing our Google Analytics request overview and will explore one of the most important advanced topics in Google Analytics — user segmentation.

Since we are dedicating an entire article on segmentation, we are going to start with a conceptual overview of segmentation to build a business case around segmentation and help you understand how segmentation research can help you better understand your customers.

Then, we are going down into the technical tunnel and explore various request parameters that are related to Google Analytics Reporting API and show you how to use those parameters to submit a request.

Finally, we will direct you to a few great segmentation resources from industry experts to help you start your segmentation journey in no time, both in the Google Analytics API, and in the user interface.

March On!

The business case for segmentation

When talking to potential clients, and stakeholders of Humanlytics, user segmentation always comes up as one of the most sought-after but yet confusing feature for users of various competencies and backgrounds.

So what does segmentation actually do?

In short, segmentation is a way for you to understand the behavior of various groups of users on your website, and each of those groups we call “segments”.

If you run an E-Commerce website that sells shoes online, only 2–3 % of the users who visit your website will end up converting and become your customers.

Segmentation — aka why was 2–3% of this pizza eaten and the remaining 97% not?

However, when you are looking at your web analytics data, it jumbles the data of your paying customer and potential customers together, unable to offer a clear reason why those 2–3% converted while the remaining 97% did not.

Using segmentation, you can create a segment for customers who have purchased products on your website ONLY, so you can understand specifically the behavior of your most important group of customers.

Furthermore, you can even create another segment for people that did not convert on your website, and compare those two segments side by side to identify the biggest factor that causes your users to pay.

That’s only one use of segmentation in your business, and you can use it for a variety of other purposes including but are not limited to:

  • Analyzing the behavior of your engaged users (people who went beyond the first page on your website or visited your website more than once)

  • Analyzing the behavior of your users from various traffic sources and channels.

  • Analyzing the behavior of a customer who has visited a specific page on your website.

  • Comparing different groups of customers that you are targeting by demographic information and identify the group with the highest conversion/engagement rate.

If any of those tasks sound intruding to you, segmentation analysis is your best friend, and you should look into it!

Advanced Segmentation Awesomeness

Let’s not stop here though. I am pretty sure you have read everything I told you somewhere else before, and those indeed cover the “basic” use case for segmentation.

But let me show you how you can use segmentation to make your analysis truly awesome (and you probably will need to use the analytics API for most of the things I am telling you here).

For example, let’s say you are running an advertisement on Facebook with 30 days attribution window. Meaning that as long as the user converts within 30 days, Facebook takes credit for the full conversion amount/sales.

This means that if a user clicked on your Facebook ad and left after seeing the first page of your website, then come back from a Google Adwords ad and ultimately convert, Facebook would take full credit of that users’ conversion — which is obviously false.

However, with segmentation, what you can do is create a segment for users that have come through Facebook with at least one session from the advertising source (you need to set this up manually), and then explore what OTHER traffic sources those users visited.

Then, you use some algorithms (based on page views, session duration, or anything as such) to assign only part of the conversion to Facebook, making attribution much more accurate and adhere to your advertising true cost.

Those are some features we are working on developing at Humanlytics and I am really excited to work on them, but meanwhile, the purpose of this section is just to give you a glimpse of what is possible with segmentation, we might touch on this in a later chapter but not likely since it requires a lot of programming and coding using multiple API sources.

User Segment vs Session Segment

In the Google Analytics UI, this concept is not very strongly reinforced, but as you start using the API more you will realize that understanding the differences between user vs session segment is in fact pretty significant.

In Google Analytics, you can create three types of segments:

  1. User segments

  2. Session segments

  3. User + Session segments

User segments — like getting someone’s internet resume in front of you!

User segments ONLY filter your data on a user level. You can filter users’ behavior by whether they have at least one transaction on your website out of all visits, their age group, gender, the channel they have visited your website through, etc.

For example, a user segment could be a user that has visited your website via a Facebook ad, and you will get all session data of that user, even if he did not visit your website via Facebook on that specific session, as long as it is that user.

On the other hand, session segments ONLY filter your data on a session-level. You can filter sessions by whether that specific session has a transaction taken place, whether that session if of a certain duration, etc. However, if you select a session segment, you might not get all of the sessions of that specific user, as some may not satisfy the session segment requirement.

Going back to the example, this means that you will only have access to a session that is strictly from Facebook ads, and you will not be able to see all traffic by users who visited via other channels.

Session segment and user segment combined together is essentially an “enhanced session segment”. In addition to satisfying the session’s criteria, that traffic must also have its user of a certain demographic, found the website through some channel, or such.

For example, if your session segment require your users to visit via Facebook ads, and your user segment requires that user to at least have one session visiting via Google, you will only get traffic that has the user visited previously from Google, and are strictly from Facebook ads — which will be a subset all session visits from Facebook ads.

Sit on this concept for a little bit, it will become handy when you are actually creating segments to identify whether your segment is really getting the data you need for your specific purpose.

Two way of segmentation in Google Analytics

In term of segmentation in Google Analytics, there are two ways of doing it —

  1. Creating a permanent segment that is stored in your Google Analytics account or

  2. Creating a dynamic segment on the fly as your analysis needs it

Currently, the permanent segment can only be created in the Google Analytics user interface, but you can access it via the API for various analyses.

On the other hand, the dynamic segment can only be defined via the Google Analytics API in your request parameter, and you can’t access or use it in the user interface.

We will briefly glance through creating a segment in the user interface, and then direct most of our attention on creating dynamic segments using the Google Analytics API.

Permanent Segment

If you are in the Google Analytics user interface, you can access most of your segments as the picture displayed below.

In there, Google has created multiple segments for you already based on those most commonly used by the users, and you can hover over the name of each of the pre-defined segments to see the defining criteria of that specific segment.

The big red button on the top left corner will enable you to create a new segment based on various conditions. Also, pay attention to the “import from gallery” option in the right of the red button — we will come back to it later.

Below display a segment creating a screen in the Analytics interface:

Most of the features are self-explanatory, feel free to explore the options yourself and try to think of the potential segments you can create.

Selecting a criteria will also change the amount of users/sessions that segment contains.

Name your segment, and you have created a permanent segment.

You can go back to the segment selection screen and select a few segments for your analysis — you will see the screen below as a result, which enables analysis to start in the UI:

Importing pre-made segments from Analytics Masters

Remember that I told you to keep in mind of the “import from gallery” option? Now let’s talk about it.

Many experiences analysts, including my personal idol Avinash Kaushik, have pre-created useful segments and shared those segment configurations in the Google Analytics gallery.

By clicking on the “import from gallery” option, you will able to access all of those pre-made segments, either using them, or draw inspiration from them to create your own segments.

You define all segments you want for your Google Analytics analysis in the “segment” parameter of your Google Analytics request, which accepts a “segment” object that looks like the following.

{
// Union field dynamicOrById can be only one of the following:
“dynamicSegment”: {
object(
DynamicSegment)
},
“segmentId”: string,
// End of list of possible types for union field dynamicOrById.
}

As displayed above, the segment object can be defined as one of the following: a dynamic segment object, OR a segment ID for a permanent segment. Notice that a single segment cannot have both parameters defined, but you can have multiple segments in your request that are of either type.

Also, you can only define four segments max with each of the analytics requests, so choose your segments wisely.

That’s a lot of segmentation and analysis for one article, so we’d figure we’d like to segment this article into two pieces! We’ll be publishing the second half of the article in just a couple of days, but until then, take a few days off this weekend to enjoy work that isn’t data science! Remember, your life needs segmenting too!

This article was produced by Humanlytics. Looking for more content just like this? Check us out on Twitter and Medium, and join our Analytics for Humans Facebook community to discuss more ideas and topics like this!