Analytics & Data

Creating Custom Segments in Google Analytics

In “Understanding Segmentation in Google Analytics,” my previous article, I explained the concept of analyzing traffic to a website in separate groups. This process is called “segmentation.”

Google Analytics offers several default segments, to automatically track common groups of visitors. These default segments include “New Visitors,” “Returning Visitors,” “Non-paid Search Traffic,” and “Paid Search Traffic.”

But many websites have segments of visitors that do not fall within these default categories. These websites need custom segments. This article will explain how to create custom segments in Google Analytics. To demonstrate, I’ll create two such segments: “Registered Visitors” and “Returning Customers.”

Creating a Custom ‘Registered Visitors’ Segment

Google Analytics cannot provide “Registered Visitors” as a default segment, because the specific mechanics of registering with a site and detecting that registration vary from site to site. The value of having this segment is clear: These are visitors who have already engaged with your site — to the point of registering. They presumably have a higher degree of loyalty and trust for the site than non-registered returning visitors, and they presumably convert at a higher rate.

You likely already detect whether a visitor is registered, so that you can provide a more personalized experience or so you can make the checkout process easier by pre-populating data.

Most sites track registered visitors from visit to visit by using a cookie placed on the visitor’s computer and then checking for the presence of that cookie — as well as the values within it — whenever a visitor comes to the site.

To segment your traffic using this information, you can set a Google Analytics custom variable or fire a Google Analytics non-interaction event when the visitor arrives on your site. Custom variables are the preferred way to go, because they can be defined as “visitor-level” values. But, there are a limited number of custom variables available in Google Analytics, so non-interaction events can also be used.

To set a custom variable, you need to choose which custom variable “slot” — 1 through 5 — you want to use. The example below uses slot 1. (For a deeper explanation of custom variables in Google Analytics, read “Mastering Google Analytics Custom Variables” on the Analytics Talk blog.)

  • gaq.push([‘setCustomVar’,1,’Registered’,’Yes’,1]);

To create a custom segment based on this custom variable, click on the “Advanced Segments” button at the top of any report, then select “Create New” and configure it as shown below.

Zoom Enlarge This Image

Custom variable segment.

Custom variable segment.

Note that if a visitor is not registered with the site, and she then registers during the visit and the custom variable gets set when she completes that registration, the entire visit will be included in the segment.

If, instead of using a custom variable, you choose to use a non-interaction event — see Google’s “Event Tracking Guide” for more on non-interaction events — use something like the following.

  • gaq.push([‘trackEvent’, ‘Registration Status’, ‘Registered’,,,true]);

To create a segment using this event — this segment will capture all visits where this event was triggered at least once during the visit, regardless of when it was triggered — set up a segment that looks like the following.

Zoom Enlarge This Image

Non-interaction event in Google Analytics.

Non-interaction event in Google Analytics.

In both cases, you can choose whether to expose the segment to all of the profiles you have access to or to specific profiles by selecting “More Options” at the bottom of the Advanced Segments window.

One final note on “registered” versus “logged in.” In some cases, these are one and the same. However, your site may track whether a visitor has registered with the site in the past, but continue to present them with an “anonymous” user experience until they actually log back in. If this is the case, be careful that you are clear with what exactly you are capturing. You can certainly capture both in separate custom variables or events if that would provide useful segmentation of your traffic.

Returning Customers

Returning customers — not returning visitors — are one step deeper than registered users. The approach of setting a custom variable or an event is very similar to the approach described in the previous section. This segment represents potential repeat purchasers. Of course, it may also represent first-time buyers who are unhappy or need customer service based on their previous visit. In either case, examining the behavior of these visitors can be valuable. Are they shopping on the site? Are they converting to orders? Or, are they clearly looking for technical support?

An important note on tracking returning customers is that it is more involved than simply setting a custom variable or event on the order confirmation page. If you do this, then this “first purchase” visit will actually be included in the “returning customers” segment. The custom variable or event must be set as returning customer on the first subsequent visit by the user, which has to be determined by other means — cookies or other.


Analyzing website traffic in separate groups can provide helpful insights. Creating and tracking these groups is called segmentation. Google Analytics offers common, default segments that many websites can utilize. For more detailed tracking, websites should create custom segments. “Registered Users” and “Returning Customers” are useful, custom segments that many ecommerce merchants could create. This article has explained how to set up those two custom segments.


Tim Wilson
Tim Wilson
Bio   •   RSS Feed