UTM segmentation

Last updated:

|Edit this page

UTM parameters are a set 5 five parameters that enable you to track the effectiveness of marketing campaigns across traffic sources. These parameters were first introduced by Google Analytics, but are now a common way to identify where traffic to your website is coming from. They are especially useful when running ad campaigns, as nearly every platform will set them when sending traffic to your website and you can set them yourself.

The parameters are appended to a URL using query parameters, for example:

https://www.example.com/page?utm_source=twitter&utm_medium=social&utm_campaign=twitter-campaign

Capturing UTM parameters

PostHog automatically captures any UTM parameters that are present when a user visits your website. These parameters are then set as properties in three places in PostHog.

  1. As properties on the event
  2. As latest and initial properties on the person profile when it is created
  3. As entry session properties

PostHog supports all 5 parameters:

ParameterPurposeExample
utm_sourceIdentifies which site sent the traffic, for example, traffic from Google or Facebook.utm_source=google
utm_mediumAllows you to track the type of link was used, for example cost per click, or social sharing.utm_medium=cpc
utm_campaignHelps identify specific promotions or campaigns, for example, when you run an ad campaign.utm_campaign=google-ad-campaign
utm_contentCan be used to differentiate the same link on different places.utm_content=footer-link
utm_termUsed to identify paid keyword searches.utm_term=analytics+open+source

Here's an example of what an event looks like when all 5 UTM parameters are set.

Sample UTM properties

Note: Although they aren't UTMs, PostHog autocaptures more properties with a similar use including:

  • $referrer and $referring_domain as event properties
  • $initial_referrer, $initial_referring_domain as person properties
  • $entry_referring_domain, $entry_gclid, $entry_gad_source as session properties Channel type is also calculated based on UTM data.

Custom UTM parameters

You can configure posthog-js to capture any custom query parameters that you want to track by adding them to the custom_utm_params array.

JavaScript
posthog.init('<ph_project_api_key>', {
custom_campaign_params: ["my_custom_utm_source"]
})
// Will automatically capture `example.com?my_custom_utm_source=twitter`

Filtering based on UTM parameters

One of the most common uses for UTM parameters is to filter down page views to only a single source or campaign. This allows you to then create insights that track and compare the effectiveness of different ad providers or using different content.

As an example, let's say we want to use UTM parameters to track the conversion rate of traffic from a particular campaign. To do this, we'll create a funnel insight with the following filter applied.

Filtering UTM properties

Note: You can only filter by UTM properties once they have been set on at least one event. If you don't see them as an option, it probably means that you haven't yet received an event where that parameter was set.

This filter means that we only want to see events where the utm_campaign was set to spring sale.

Next, we can get a better idea of which platforms are giving us the best result by breaking down based on the UTM Source.

Breakdown by UTM Source

This enables us to see how our conversion rate compares across platforms where we're running our ad campaign and figure out where we're getting the highest-quality traffic from.

Questions?

Was this page useful?

Next article

HogQL

HogQL is our take on SQL (Structured Query Language), a language used to manage and access data. It is effectively a wrapper around ClickHouse SQL , with tweaks such as simplified event and person property access, null handling, and visualization integrations. HogQL is currently in public beta . This means it's not yet a perfect experience, and the language itself may still change. Follow along with the development here . HogQL expressions HogQL expressions enable you to use database…

Read next article