Using Amplitude? Here’s code to help you segment by utm parameters

Ron Shoshani
R&D and Stuff
Published in
2 min readOct 31, 2014

--

I’ve been using Amplitude.com for a while now and it’s a really great analytics tool. One thing that is missing out of the box is the reporting of utm parameters in order to segment your data by source, campaign, and so on.

What are utm parameters?

Websites get traffic from a lot of sources — campaigns that you launch, blog posts, newsletters, etc. Which sources are most effective? Which audience converts best on your site?

That’s what utm parameters are for. You add them to your url, and can then segment the results by them. An example url would look like this: http://www.GeeksAreUs.com/?utm_source=AdWords. Here’s a quick explanation about the standard utm parameters:

  1. utm_medium — top level grouping, indicates the overall channel (PPC, E-Mail, etc).
  2. utm_source — the provider within the channel that brought the traffic (AdWords, Newsletter, etc).
  3. utm_campaign — your marketing campaign name.
  4. utm_content — use this to differentiate between variations in content and message of your campaign.

Reporting utm parameters in Amplitude

Amplitude has a notion of User Properties, which is actually metadata that you can attach to a user. What we need to do is retrieve the utm parameters in case they are present in the query string, and report them as user properties.

Here’s the code to do it:

[github file = “/ronshoshani/amplitude-utm/blob/master/amplitude-utm.js”]

Usage in Amplitude UI

First of all, let’s see the user properties in the UI. You can see that utm_campaign was reported for this user:

Now where ever you have an option to segment the results, you will see the additional user properties. As an example, here’s the Segments panel in the Funnels tab:

Summary

I have asked Amplitude to add this capability to their JS library, so I’m hoping it will be added in the future. For now, you can use something like the above code.

--

--