Knowledge Base      


What is a “query string”?


A “query string” is one of several methods of passing data from one web page to another. You’ve probably seen URLs that look like this:

https://www.calendar.com?day=25&month=1&year=2024

That URL contains two parts, separated by the “?” character. The part before the “?” mark is the link and the part after the “?” mark is data being passed to the link.

In effect, the URL above says to go to the website www.calendar.com and pass the data
 
     day = 25
month = 1
year = 2024

Who knows what calendar.com is going to do with that data, but it’s reasonable to assume that it has something to do with the date “January 25, 2024.”

When you look at the URL in this example, the query string is introduced by the “?” mark, followed by the actual query string, which is made up of name=value data pairs, each separated by the “&” character:

https://www.calendar.com?day=25&month=1&year=2024

The “&” character is commonly pronounced “and” in computer programming languages, so you can loosely think of that query string like this:
 
     ?  (pass the following data:)
day = 25,  and
month = 1,  and
year = 2024

In this example, each of these name=value pairs show numerical values, but values can also contain numbers, characters, and symbols. The month value could just as easily have been either of these:

month=jan
month=[January]


It’s up to the target website to determine what the data means and how you must pass it in.

Query strings are used in several places in ClickMagick. You’ll find them in tracking pixels, Postback URLs, affiliate network integration, and other places.

You may need to edit query strings at times or add a new name=value parameter. For example, let’s assume you have a URL, and you need to add this ClickMagick integration parameter:

s1=[clickid]

If the URL doesn’t have a query string yet (meaning there’s no “?” mark yet), you’ll need to create the query string by adding a “?” mark followed by the new parameter:

https://www.website.com?s1=[clickid]

On the other hand, if the URL already has a query string (meaning there’s already a “?” mark), you would add the new parameter to the end using the “&” character:

https://www.website.com?id=475&s1=[clickid]

You can search the web for a much more thorough discussion of query strings, but this should get you through 97% of the situations you’ll ever encounter.


Encoded Query Strings

You’re sure to run into “encoded” query strings. These are query strings where some characters are replaced with a more “machine-friendly” form. For example, the space character will typically be replaced with %20, colons with %3A, and slashes with %2F. Don’t be surprised if you see https:// encoded as https%3A%2F%2F. Check out W3Schools.com’s complete list of URL encodings.

HTML has a different way of encoding characters using named “entities.” For example, the “&” character itself will often be replaced with & amp;. This creates some unusual-looking query strings, especially when you paste an otherwise normal-looking link into a Page Builder and you see your name=value pairs separated by & amp; entities when you view your page source. You can find an extensive list of these HTML entities at W3Schools.com.

You won’t need to worry about encoded query strings in ClickMagick, but at least you’ll know what those %## and &entity; encodings are when you do see them.


Value-less Parameters

Another thing you’ll see are query strings where the parameters don’t have any values, such as:

https://www.calendar.com?day=&month=&year=

Parameters without values are perfectly fine. It just means they aren’t specified. For this www.calendar.com example, this might mean “display today” since an actual date is not specified. Using value-less parameters is quite common, so don’t let it confuse you if you see them.

 
Tip: If you want to pass a query string from a tracking link to its Primary URL, you can use the [query_string] token. See the section on Passthrough Tokens in this article:

What data or tokens can I pass to the URLs I promote?
 
Note: For a complete description of query strings, take a look at this Wikipedia entry:

History and Use of Query Strings


Article 177 Last updated: 03/13/2023 7:51:24 AM
https://www.clickmagick.com/kb/?article=177