How to force a hit-level segment in Universal Analytics

In Universal Analytics, you can build a user-level or session-level segment. Here’s a nifty little hack to force a hit-level condition to get the data that you want.

Note: This how-to is for forcing a hit-level condition within a session-level segment. It is not commonly understood that if two criteria in a user-level segment are in the same condition filter, then they have to occur in the same hit. This can be achieved within a user-level segment, with the default behaviour of adding multiple criteria within a single condition, separated by AND statements. 

Doing this with user-level segments, however, will include sessions for those users where they did not meet your criteria. As a result, it’s often necessary to do this within a session-level segment, and it is that requirement that is covered in this guide.

Typically, within session-level segments, the criteria you want to base your segment on can happen independently within the session. So, for example, you might want to look at sessions where the landing page was the homepage and the session resulted in a transaction. These two criteria are independent of each other i.e. they happen at different points in the session. Therefore, you can do this by simply adding additional conditions to the segment and this will give you exactly what you want.

Sequence-based segments

However, there are times when you need to be more specific and tie two criteria together within a single hit. The most common example of this is when you want to include sessions that involved the purchase of a specific product i.e. you want to tie a product name to a purchase hit. This sounds like it should be easy to do and it’s a common requirement, but Google Analytics only offers session-level and user-level segmentation, and what we need here is actually a hit-level condition, as we want to specify a product that was contained within a purchase hit.

The problem with trying to do this within the segment builder for a session-level segment is that it will only look to see if each of the criteria happened at some point within the session, and each criterion is looked at independently. So, if we tried to do this…

…it would show us this:

Which looks sensible, however, it is very misleading. This will include sessions where a product name exactly matching “Delon Velvet Chair” was included in a hit and in the same session, the unique purchases per hit is greater > 0. However, what it does not specify is that the hit the product name appeared in was the same hit as the purchase occurred. So, it’s entirely possible that this session involved the user viewing the “Delon Velvet Chair” product page (or that product appearing in a product list they viewed), but purchasing an entirely different product.

Session-level segment criteria

To ensure that we only include sessions where the Delon Velvet Chair was purchased, we need to force the segment to tie the product name criteria to the unique purchase criteria in the same hit. This is where the hack comes into play.

In the segment above, we are using a sequential condition, and this is the hack. Sequential segments evaluate each ‘step’ as a single hit, so this sequential segment is the equivalent of a hit-level segment.

Below are the results of the two segments we have created: the incorrect condition-based segment and the correct sequential segment.

As mentioned, the incorrect condition-based segment is over-including, as it will include sessions where the product name appeared in a hit that was separate from the purchasing hit. However, the sequential segment forces the condition to be hit-level and therefore this will only include sessions where the product name (in this case, “Delon Velvet Chair”) was in the same hit that the purchase occurred (unique purchases per hit > 0).

Prerequisites

  • The interactions you wish to include in your segment are already being tracked in Google Analytics.
  • Enhanced Ecommerce is being used if wanted to segment by product(s).

Use cases

  • Segmenting purchases of a specific product (or products) within a single transaction.
  • Seeing combinations of events triggered on specific pages.

Share:
Written by

Dara is CEO at Measurelab. He is an active member of the Google Analytics Partner community, a regular industry speaker and GA trainer.

Subscribe to our newsletter: