Query String
Query String A query string is the part of a URL that comes after the question mark (?) and carries

A query string is the part of a URL that comes after the question mark (?) and carries data as key-value pairs. It passes extra information to a web page or server without changing the page’s base address. Each pair has a name and a value, and multiple pairs are joined with an ampersand (&).
Query strings let one URL serve different content or trigger different behavior. Search results, filtered product pages, and campaign tracking all rely on them.
https://example.com/products?category=shoes&color=red&sort=price
Here the query string is category=shoes&color=red&sort=price. It tells the page to show red shoes sorted by price.
How a Query String Works
A query string begins at the first ? in a URL and continues until the end or until a fragment (#).
The structure follows a fixed pattern:
- The
?opens the query string. It separates the path from the parameters. - Each parameter is a
key=valuepair. The key names the data, the value holds it. - The
&separates pairs. Every additional parameter after the first is preceded by an ampersand.
The server or front-end code reads each pair and acts on it. A sort=price value tells the page how to order results. A page=2 value loads the second page of listings. The browser sends the full query string with the request, so the receiving system decides what each parameter means.
Query String Parameters
Query string parameters are the individual key=value pairs inside the string. They fall into a few practical types.
- Filtering parameters. Narrow what a page displays, such as
color=redorsize=large. - Sorting and pagination. Control order and position, such as
sort=newestorpage=3. - Search parameters. Carry user queries, such as
q=running+shoes. - Tracking parameters. Attribute traffic to a campaign. UTM parameters like
utm_sourceandutm_mediumlive in the query string. - Session or state parameters. Pass IDs or tokens, such as
ref=newsletter.
Values that contain spaces or reserved characters must be URL encoded. A space becomes %20, and a literal ampersand becomes %26, so it is not mistaken for a separator. To assemble a clean, correctly encoded string, linkutm’s query string builder adds each parameter and handles the encoding for you.
Query String Best Practices
Well-formed query strings keep tracking accurate and pages crawlable.
- Use lowercase consistently. Many systems treat
Color=Redandcolor=redas different values. Google Analytics is case sensitive. - Encode special characters. Always encode spaces and reserved symbols inside values to prevent broken parameters.
- Keep parameter order stable. Reordering parameters can create duplicate URLs that search engines see as separate pages.
- Avoid unnecessary parameters. Strip empty or redundant pairs. They clutter analytics and dilute crawl efficiency.
- Set a canonical URL. For pages that vary only by query string, a canonical tag tells search engines which version to index.
Query String vs Path Parameters
A query string and a path parameter both pass data, but they sit in different parts of the URL. A path parameter is part of the URL path itself, such as /products/shoes. A query string sits after the ?, such as /products?category=shoes.
Path parameters suit stable, hierarchical content that should rank in search. Query strings suit optional, variable inputs like filters, sorting, and tracking. Most campaign tracking uses query strings because the parameters are optional and machine-read, not meant to be human-readable URLs.
Frequently Asked Questions
What is a query string in a URL?
A query string is the section of a URL after the ? that holds key-value pairs. It passes data to the page, such as filters, search terms, or campaign tags. Pairs are written as key=value and joined with &.
What is an example of a query string?
A common example is ?q=running+shoes&sort=price. The q parameter carries the search term, and sort controls the order. Each pair sits after the ? and is separated by &.
What are query string parameters?
Query string parameters are the individual key=value pairs inside a query string. Each one passes a single piece of data, such as color=red or utm_source=facebook. A page can read one parameter or many.
Are query strings case sensitive?
Query string values are often case sensitive, especially for analytics. Google Analytics treats utm_source=Facebook and utm_source=facebook as two different values. Use lowercase consistently to keep your data clean.
To build a correctly formatted query string in seconds, try the free query string builder at linkutm.