Flow: Parse UTM Parameters from URL

Updated 2020-01-09: Improved the Flows to get only the UTM parameters to parse. Templates updated also.

For those unaware, what are UTM parameters, they are additions to the URL that help marketing people segment a link in a specific campaign, medium, and content. You can see this usually when you open a link, in an email or click specific links in websites, but they always keep a format like this:


Google Analytics, or whatever system you’re using, pick them to keep tabs on what’s working and what’s not. Google Analytics introduced UTM parameters for that specific purpose, and used widely in the industry, even in competing services.

Why extract them

Sometimes it’s handy to have that information elsewhere so, given a specific URL, we can quickly parse these values and get them individually and store them. For example, if you want to keep a list of all parameters used in campaigns and provide that list to the marketeers, then you need to get them individually. You can give them a Flow that they can feed a URL, and that information is automatically stored for them to reference in the future.

Flow to get the parameters

I’ve built two templates that you can find in my template section, one if you want to have the full flow and another if you’re going to have a Flow that performs these actions and then returns the values. The later can be quite useful if you want to re-use this logic elsewhere but requires you to have a premium account because we’re using the “Request” trigger.

There are three main steps for parsing the URL.

Get the individual elements

Let’s use the example above and split it using the & as our separator.

The formula is quite simple:


We’ll get something like this:


Get the values of the elements

Now that we have the items, we need to get each of them and split them again, this time by “=.”

The formula is the same:


And we’ll get something like this:

First run:

Second run:

Third run:

Setting the values to variables

The rest is trivial. Add a Switch and set them to the correct variable.

Notice that the default is “utm_medium.” It’s usually the first one, and we’ll get the URL also, so if we can get the other two, then we’re sure that the last one is this one.

If you’re using the Request trigger

The “Request” trigger allows you to centralize a lot of business logic into one Flow. There are only two extra things that you need to take into consideration that I’ll highlight now.

I’ll include, in the template, archive an example of a Flow that calls a service that is a “Get” instead of a “Post” so that you can see the differences.

Request Type – GET

The request type needs to be “Get,” since we’re trying to get something back from the service, in this case, the values parsed. To do this, just set, in the advanced settings, the “method.” Notice that we’re not expecting anything in the body of the request since the URL is in the “Header” portion of the request

Send Response

Now let’s prepare the information to send back to the caller of the service. To do this, do the following:

The calling Flow will get a helpful JSON formatted reply with the UTM parameters passed.

One more thing

I got an email from Sam (my thanks to Sam!) that had a perfect point. The templates work if you have URLs that contain UTM parameters only. If not we need to add an extra filter to filter them out.

Here’s the change:

The formula to filter is the following:

indexOf(item(), 'utm_')

We’ll filter out all items that don’t contain the string “utm_.” The templates were updated to consider this.

That’s it.

It’s quite simple, and it can give you a lot of flexibility to parse information internally.

There’s no need for you to build this yourself. I have a template that you can download and it in your instance. Just use the template archive, and you’ll find these and more.

Have a suggestion of your own or disagree with something I said? Leave a comment or interact on Twitter and be sure to check out other Flow-related articles here.

Photo by Nikita Sypko on Unsplash

Manuel Gomes

I'm a Project Manager with experience in large projects and companies. I've worked in the past for companies like Bayer, Sybase (now SAP) and I'm currently working for Pestana Hotel Group.

View all posts by Manuel Gomes →

2 thoughts on “Flow: Parse UTM Parameters from URL

  1. Just wanted to say thank you for answering this question for me on the forum. This is a great article. Loving Flow and what it can do.

    I’m finding some of the out of the box triggers and steps are super powerful. You can integrate with almost any system using them (not just ones with existing connectors in Flow).


Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: