How to Use Query Strings and Parameters for Marketers – Fully Explained

What is are Query strings and Parameters? Little bits of information encoded directly to the URL. It is often used by Marketing Tools such as Google Analytics, AdWords, Facebook and more. In this video we are going to learn how to encode our own information into a Query String and make it useful to us marketers

Hi there and welcome back to another video of teaching you the data-driven wave of digital marketing. My name is Julian and today we’re gonna learn about query strings and how we can use them as marketers.

What are Query Strings?

Now when we talk about query strings, we actually need to take a closer look at the URL that you see in your URL bar up here. Let’s inspect this a little further. I’m going to copy this out and put this into the spreadsheet, here. And we have different components of a URL, actually. You might be familiar with them already. At the beginning here we have our protocol. Then this is followed with our host name. After that, we would have the path, and then after a question mark right here, this is the tail of a URL, we actually have our query string. Now what does this actually do?

If you know what a URL actually is, it is an address that gives you back a website. Now this address is split up in these different components and they do different stuff for you. First of all, the protocol would be the communication method between your browser and the server, so it knows what to expect. Behind the host name is usually an IP address that identifies the server. And then the path would give you back certain resources, certain folders inside of the server and display information for you. Now if you change around any of these components, your website most likely would change. But the query string is actually something, if we would leave that out, for example, for this page. It doesn’t do anything to the page. We would still have the same information available.

Why Query Strings are Important

So why is this query string important? Well, it actually transfers different information that might not be relevant for the server side, but for other tools, in our case, that would be Google Analytics. Now if you’re familiar with UTM parameters, we have another video on that, as well. Then you might know that these actually help us to classify the traffic, where the traffic came from, and puts them into, for example, this Source/Medium report here where we can identify where the user came from, if he used UTM parameters. But you might have also seen other cases of UTM parameters on different websites.

The Parts of a Query String

Now, let’s look at query strings a little closer and take them apart. So first of all, let’s copy this URL and go into our second sheet here, our query string. Now this is our URL, that query string, as we already said. It’s actually just this part after the question mark. Let’s put that in here. Make this a little bit bigger. And inside of this query string, we have an identifier, an identifier where the query string actually starts. And that’s the question mark. Then we have connectors in there and these connect our different key value pairs. These are usually marked by the & sign. And then we have key value pairs. And this is the information that actually is encoded in this query string. Now you just need to know how to read these query strings and the key value pairs, also called URL parameters. And these parameters are actually between the question mark and the separators, here. So we have one, two, and three. Let’s go ahead and dissect them. First, we have here our newsletter. Then we have our medium, Email. And we have our campaign right here. Now these are Key-Value pairs. These are the query parameters, also called URL parameters that make up our query string.

Separating Query Strings in to Key-Value Pairs

If we separate them further, we actually get to the Key-Value pairs. Now, the separator here is the equal sign that actually separates the key from the value. So, in our first example here, we have our UTM source. And our value would be newsletter. Now the second one would be UTM medium. And our value would be Email. And our UTM campaign would be summer15. Now this is the information that is actually encoded inside of our query string. You just need to know how to read them.

There are a few rules, but once you understand how you can take this apart, you get to the key value pairs and the information that Google Analytics can actually read. Because, as you might know, in our all traffic report, we have our Source/Medium. And this is a category that we can classify our traffic in. And now we are telling Google Analytics explicitly where we want to classify this traffic end. So our UTM source should be newsletter, our medium should be Email, and our campaign should be summer15. Now we can try this all out. This information’s in here. I’m gonna reload the page and go into the realtime reporting of our account. We see that there’s a new page view that has just been generated. And if we go down here, wait for a while. It needs to pick it up first. Should be able to go to Traffic Sources. And we see here that the traffic that we just received came from medium, source newsletter, and the campaign, summer15. So Google Analytics has picked up this information and is now classifying this traffic in this way.

Now this is one use case of query strings in your URLs. If you want to tell Google analytics explicitly where the traffic that just reached your page came from. Now you could use this link, with this tag URLs in your Facebook campaigns or in your email newsletter, for example. We have another special video on that that you can check out right here. Now, you need to be careful once you write these value pairs in here, you can’t just type in anything because they actually need to be URL-encoded.

Using Multiple Values & Symbols in a Query String

Now for example, if you have multiple values in here, they actually need to be connected with a plus sign. So, a space would be a plus sign, in this case. Special characters need to also be encoded. The equal sign for example, or umlaut, as well. Now the best method to do this is actually find a URL Decoder/Encoder and type in any of your strings that you want to change. Encode them and it will give you back the string that you can use in your URL, as well. All right, just to recap, we know now what the query string is and what it’s for.

Use Cases for Marketers

Now how would you use this as a marketer? There are several use cases. Sometimes query strings are used to communicate something with the server, send information back and forth. But they can be also used in marketing tools. We already discovered one use case with UTM parameters that we can use to tell Google Analytics explicitly if we want to send the traffic and which category. And by the way, we also have our UTM tagging tool that you can use in order to make more sense of this. By putting the campaign Medium/Source in a spreadsheet, and the URL will be automatically built for you. But there are also other ways that Google Analytics makes use of the query string.

Cross Domain Tracking

One is cross-domain tracking. So if you go to Measure School, here. They actually have a link to another website that we have. And if I click on this Login link, here. Then there is a query string attached with this huge number at the end. Which actually tells our Google Analytics on our second website, which is a different domain, here, that’s, that we just came from our first property and we would like to stitch both of these sessions together. This is also known as cross-domain tracking. So we have cross-domain tracking installed here and if the query parameter wouldn’t be transferred onto this link, we wouldn’t be connecting our two domains together and Google Analytics would see this as separate traffic. So this is just one more use case where the query string is very important.

Getting Value of Site Search

Another case that you might be aware of is when we go back to our Demoshop here and type something into the search. We actually have a query string here with the s and equals sign and then woo, which is the value of this s key, which resembles our search. Now, in this case, our search actually communicates an important value to our server. And he authors the results and the content down here. If I would put something else in here, then obviously this would also change our search results here. But we can use this in Google Analytics as well, because there’s actually a report in the Behavior section called Site Search. Now how does that get filled? We just need to give Google Analytics our key of our query string, right here. So in our case that would be s. We could then go into our Admin section and say that we have identified under the View Settings our Site Search. Right here, Query parameter, and we can type in our s, in order for Google Analytics to fill our reports correctly. So again, here we use the query string to identify our search results.


Another example would be Email. So if you’re here in our Email marketing tool, of Drip, where we have, for example, a variable that’s oftentimes possible in Email marketing tools to insert a variable from a custom form field, can also use that in a link. So, for example, here we have a link that we sent out. And we have a query parameter attached. And right here, this is, again, our UTM tagging. But also, at the end, and this is just attached with the & sign again, we have here our first name equals and then our subscription field that will be dynamically replaced to whatever user we sent this out to. Now once the user gets the Email, right here, he would obviously get this replaced with the variable, and the link, as well, would then feature a replaced value right here, from Julian. Now this could then be picked up, and, for example, forwarded on to a Contact Us field. Right here, that would be automatically filled.

We have another video on this, as well. Now these are just a few use cases how you can use query parameters. It really depends on the tools and the methods that you wanna use them in. I think, to understand query parameters and query strings is very important as a marketer, in order to be able to see what information gets sent back and forth, and how to manipulate these query strings for your own marketing efforts.


All right, so did you like this video? Then, don’t hesitate. Give us a thumbs-up. And if you wanna see more, then you can go over to the next video over there or subscribe to our channel right over there, because we will bring you new videos just like this one every week. Now, my name is Julian, see you in the next one.


Master Data & Analytics with Measuremasters

Exclusive Courses & Workshops | Ongoing Troubleshooting | Support Resources, Tools & much more
Inline Feedbacks
View all comments

now it's time to

Start measuring like a master

Itching to jump into the world of MeasureMasters? This is what you have to look forward to.