This document provides an overview of segments in Google Analytics.
Overview
Segments allow you to select users and sessions to answer questions that are important to your business. For example, users that have completed at least 2 transactions with a lifetime revenue of over $1,000, or users who visited first on a mobile device followed by a desktop browser.
This document will familiarize you with the Google Analytics user model and the fundamentals of creating segments.
Google Analytics User Model
Reviewing the Google Analytics User Model first will help you conceptualize how segments work.
There are three major components to the Google Analytics user model:
- Users — At the basic level you have users.
- Sessions — A user arrives at and interacts with your property. All of these user interactions are grouped into what is referred to as a session.
- Hit — During a session the user interacts with your property. Each interaction is referred to as a Hit. Example hits include pageviews, events, transactions, etc.
A single user can have multiple sessions, and each session can have multiple hits. Visually, this is represented below:

Once you understand how users are modeled in Google Analytics, the next step is to look at how to create segments.
Segments Examples
To create a segment you define the condition and the dimensions and metrics values you’re interested.
For each example below there is a segment description, the equivalent API Syntax for the segment parameter, and a user model representation.
The legend for the model representation is:

The examples below illustrate the following:
Conditions
Use conditions to select users or sessions based on dimensions and metrics values.
Dimensions
Select users or sessions based on dimension values.
Users
Select users who came from
Canada.
users::condition::ga:country==Canada

Sessions
Select sessions that came from
Canada.
sessions::condition::ga:country==Canada

Metrics
Select users or sessions based on single or totaled metric values.
Users
Select users whose total revenue in a single
transaction was greater than $100.
users::condition::perHit::ga:transactionRevenue>100

Select users whose total revenue across all
transactions within a session was greater than $100.
users::condition::perSession::ga:transactionRevenue>100

Select users whose total revenue across all
transactions in the date range was greater than $100.
users::condition::perUser::ga:transactionRevenue>100

By default, when selecting users, metric values will be totaled at the user
level. So you can simplify this to:
users::condition::ga:transactionRevenue>100
Sessions
Select sessions where total revenue in a single
transaction was greater than $100.
sessions::condition::perHit::ga:transactionRevenue>100

Select sessions where total revenue across all
transactions in a session was greater than $100.
sessions::condition::perSession::ga:transactionRevenue>100

By default, when selecting sessions, metric values will be totaled at the
session level. So you can simplify this to:
sessions::condition::ga:transactionRevenue>100
Excluding Conditions
NOT Operator
Use the !
character to negate a condition and exclude the
sessions matching that condition.
Exclude sessions where the exit page exactly matches
the root page path.
sessions::condition::!ga:exitPagePath==/

Combining Conditions
AND Operator
Use the ;
character to combine conditions using the AND
operator.
Select users who came from Canada AND
whose total revenue across all transactions in the date range was greater than
$100.
users::condition::ga:country==Canada;users::condition::perUser::ga:transactionRevenue>100

Since these are both user conditions, you can simplify this to:
users::condition::ga:country==Canada;ga:transactionRevenue>100
OR Operator
Use the ,
character to combine filters using the OR operator.
Select users who came from Canada OR
who came from Mexico.
users::condition::ga:country==Canada,users::condition::ga:country==Mexico

Since these are both user conditions, you can simplify to:
users::condition::ga:country==Canada,ga:country==Mexico
Since the condition dimensions are the same, you can use a regular expression
to simplify to:
users::condition::ga:country=~Canada|Mexico
Sequences
Use sequences to select users or sessions based on sequential conditions.
Select users who visited on mobile immediately
followed by a visit on desktop.
users::sequence::ga:deviceCategory==mobile;–>ga:deviceCategory==desktop

Select users who visited on mobile followed
by a visit on desktop.
users::sequence::ga:deviceCategory==mobile;–>>ga:deviceCategory==desktop

Combining Users and Sessions
You can select users and sessions to create a segment. Users will be selected first and sessions will be selected from the subset of users.
Select sessions where total revenue in
a single transaction was greater than $100 from users who visited on mobile followed by a visit on
desktop.
users::sequence::ga:deviceCategory==mobile;->>ga:deviceCategory==desktop;sessions::condition::perHit::ga:transactionRevenue>100
Next Steps
Review the Segments Dev Guide for complete details on the segments syntax and how to query segments in the Core Reporting API.