UTM Parameters as Events

If you're using UTM parameters for links to your site, you can segment users based on which UTM campaign they arrived through by tracking an event in Drift.

What's a UTM Parameter?

KissMetrics has a great writeup here!

For example, suppose we have a Twitter ad campaign with this URL: https://blog.drift.com/?utm_source=twitter&utm_campaign=abm-meetup

When a user lands on the page, we can check if the URL contains utm_source=twitter and utm_campaign=abm-meetup, and then track a "Clicked Twitter Ad" event for that user in Drift. Once the events are being tracked in Drift, we can create a dynamic segment for users who have tracked that event at least once.

Here's the complete code example:

window.drift.on("ready", function() {
  var queryString = window && window.location && window.location.search
  if (queryString) {
    if (/utm_source=twitter/.test(queryString) && /utm_campaign=abm-meetup/.test(queryString)) {
      window.drift.track("Clicked Twitter Ad ABM Meetup")

You can even copy and paste the above example onto your site. You'll want to change the name of the event passed to drift.track and also probably check for different UTM parameters.


Make sure the code gets executed after the Drift JavaScript Snippet by placing its script tag after your snippet's script tag.