Filtering Session-Level and User-Level Custom Dimensions


Use Session- and User-Level Custom Dimensions in Filtered Views

Custom dimensions are incredibly useful for gaining a new perspective on your data, such as by identifying sessions where users are logged in, whether users are members of your organization, account holders, or if they belong to a particular audience type or role, for example.

To get even more granular, you can filter your Google Analytics traffic with these custom dimensions as well. For example, Jon Meck wrote a useful post in the past that included the use of a custom dimension as an option for excluding internal traffic. In addition to creating a method of segmenting all of your standard reports by a custom dimension, this can also be helpful in preventing problems with sampling, for example.

Note that this post assumes you already have custom dimensions set up and passed to Google Analytics correctly on your website. You can find out how to do that in one of our previous blog posts: Defining Audiences with Google Analytics Custom Dimensions.

How to Filter Traffic with Custom Dimensions

To do this, you will need to create the filter at the view level (instead of at the account level) because custom dimensions are defined at the property level. The custom dimensions that you have created will appear at the very bottom of the Filter Field drop-down list.

Filtering with Custom Dimension

For example, here we have created a new view which we are filtering based on a custom dimension we have set for sessions that are defined as logged-in:


But how exactly does it work? What if I have some users who do not immediately trigger the custom dimension during their visit to my website (maybe they view a few pages before reaching one that sets the dimension) – how will that data look in my new view? Will Real Time reports show all of the hits?

If you’re doing any kind of analysis based on session- or user-level custom dimensions in particular (such as any of Sayf’s recommendations), you will undoubtedbly ask yourself one of these questions at one point or another.

Unlike hit-level custom dimensions (or product-level dimensions, for that matter), session-level and user-level dimensions are applied to all hits defined in their scope – this is important to understand when trying to segment data in a view based on filtering with custom dimensions.

Let’s review how the data will look in different views that include or exclude traffic associated with user-level and session-level custom dimensions.

Custom Dimension Scopes

As you likely already know, custom dimensions can be applied at the hit level, session level, user level or product level. This is very important to keep in mind, as the scope of the dimension plays a major role in how the data will appear in your reports. Specifically:

  • Session-level custom dimensions are applied to all hits in a single session, regardless of when the specific hit occurred that set the custom dimension.
  • User-level custom dimensions are applied to all hits in current and future sessions (at least until the value changes).
  • Hit-level custom dimensions are applied to only the hit with the dimension is sent to Google Analytics.
  • Product-level custom dimensions are applied to the product with which the dimension is sent to Google Analytics.

For more information on scope, take a look at Google’s support page.

During processing, custom dimensions are applied to the appropriate hits based on their scope so that you can see all of the hits associated with a given custom dimension in your standard reports.

This means that, within our standard reports, we are able to see all of the pageviews that occur within a session where a session- or user-level dimension was applied, regardless of when exactly that dimension was applied.

Including Traffic Based on a Session-Level Custom Dimension

Say you have a custom dimension at the session level, called “logged-in,” that you set to either “true” or “false.” You can use this to create a View in your Property that only includes traffic for sessions where “logged-in” equals “true.” If a user visits your website and views two or three pages before actually logging in, we should still see this user’s initial pageviews our filtered view, even though they did not log in immediately.

Session-Level Custom Dimension

The custom dimension value is stored for all of the hits for that entire session, all of the hits before the custom dimension was set and continuing for as long as the session remains alive.

Those initial, pre-logged-in pageviews will appear in our Top Pages report in Google Analytics in both views after Google Analytics has processed the hits. You will not see them in your Real Time reports, however, so keep this in mind if you are doing any debugging using the Real Time reports.

Including Traffic Based on a User-Level Custom Dimension

The same deal applies for user-level custom dimensions. At the same time a user logs in, you could also pass in some information that you know about that user, like their gender or age, or something specific to your business, like a member classification. You could then also create a View with a filter to include only “Students” or “Customers,” or in the example below, “Gold Members.”

Even if the custom dimension is set in the middle of a session, we’ll get the information about that entire session and every session after that until the value changes or cookies are changed.

User-Level Custom Dimension Member Type

Excluding Traffic Based on a Session- or User-Level Custom Dimension

If you exclude traffic based on a session-level custom dimension, such as excluding logged-in sessions, all of the pageviews during a session where the dimension was applied will be excluded from your standard reports regardless of whether or not the user immediately logged in. So if a user views two or three pages before logging in later in the same session, all hits occurring in that session prior to logging in will be filtered out of your standard reports.

The same goes for excluding traffic based on a user-level custom dimension, such as excluding “member” traffic. If a user comes to your website, views a few pages prior to being labeled as a “member,” those pageviews will also be filtered out of your standard reports – along with all future hits from this user.

Again, keep in mind that because filtering occurs during processing, your Real Time reports may not show accurate information when filtering by session-level or user-level custom dimensions. In other words, if you are excluding traffic from logged-in sessions, but some users view multiple pages prior to logging in, your Real Time reports will still show those pre-logged-in pageviews.

Sidenote – if a user has a session-level custom dimension applied that defines them as a logged-in user, and then they log out, the custom dimension value of “false” is applied to all of their hits for that session. This means their entire session will be considered a “logged-out” session! If your website has the ability to log out and encourages that behavior, consider using a hit-level custom dimension instead.

Amanda Schroeder is an Analytics Engineer and comes from the marketing industry where she found a need for accurate, insightful data that could aid in making results-driven decisions. Amanda’s passion for building solid measurement strategies and connecting all the pieces of integrated digital and traditional marketing campaigns has led her to her current role at LunaMetrics.

  • Adrian Ignatescu

    Absolutely great post. The examples with session/user id scopes are great!

    • Amanda

      Glad you found it helpful!

  • Brad Booth

    Great blog! This helped me out since I setup a new filter to exclude data from my view, but I was still seeing data in the real-time reports. After running the daily standard reports, the data was excluded. Thanks!

    • Amanda

      I wrote this post out of the same curiosity 🙂 Glad you found this useful!

  • Alice

    Fantastic post!
    I’m working to setup new views and I would like to have more clear the difference between including traffic based on hit – level and based on session – level custom dimension.
    What happen when I include traffic by hit – level custom dimension?
    The sessions are the same of session – level scope?

Contact Us.


24 S. 18th Street, Suite 100,
Pittsburgh, PA 15203

Follow Us



We'll get back to you
in ONE business day.