What is a query string?
How a query string is built
In example.com/shoes?color=black&size=42&utm_source=newsletter, the query string is color=black&size=42&utm_source=newsletter. RFC 3986 defines it as everything after the first question mark, up to a # or the end of the URL. The standard does not dictate the key=value format, but nearly every website and analytics tool uses it:
- ? starts the query string. Only the first ? counts; later ones are part of a value.
- key=value is one parameter, also called a URL parameter or query parameter.
- & separates parameters. Their order usually does not matter to the page.
- # ends it. Anything after the # is the fragment, which the browser never sends to the server.
- Spaces and reserved characters inside a value are percent-encoded: a space becomes %20 (or + in form encoding) and an & inside a value becomes %26.
How browsers and code read it
In JavaScript, URLSearchParams reads a query string into pairs. MDN notes a few details worth knowing, because servers and analytics tools often follow the same conventions:
- A + in the query string is read as a space, so a literal plus sign must be sent as %2B.
- A key can appear more than once (tag=a&tag=b). get() returns the first value; getAll() returns every value.
- Keys and values are case-sensitive: utm_source and UTM_Source are different keys, and GA4 only reads the lower-case utm_ names.
What query strings are used for
Most query strings you see on links fall into a few groups. Tracking tags such as utm_source, utm_medium and utm_campaign tell analytics where a visit came from. Click IDs such as gclid (Google Ads) and fbclid (Meta) let an ad platform match a later sale to the ad click. Page state such as search terms, filters, sort order and page numbers changes what the page shows. Session or sign-in values, sometimes sensitive, should never be shared in a public link.
Because the query string is part of the address, it also travels to other places: browser history, server logs and, depending on the referrer policy, the next site the visitor opens. Browsers' default policy, strict-origin-when-cross-origin, sends only the origin to other sites, not the path or query, but do not rely on that for secrets.
Query strings and short links
A short link stores the whole destination, query string included, so a long tagged URL becomes a few characters. When someone opens it, the shortener redirects to the full address with every parameter intact. BN Shortener's UTM builder adds the five UTM fields and keeps the rest of your existing query string exactly as it was.
Ad platforms add their own parameters to the link you give them. If that link is a short link, the click ID lands on the short link, not on your page. In BN Shortener, turn on pass visitors' link parameters on for the link, and parameters added to the short link, such as gclid or fbclid, are added to the destination so conversion tracking keeps working. To see a URL's parameters one by one, paste it into the free URL parser; to build tagged links, use the UTM builder.
Related: UTM parameter, URL encoding, /tools/url-parser/, Uniform Resource Locator (URL)
Sources
- RFC 3986: Uniform Resource Identifier (URI), Generic Syntax, checked 2026-10-24
- MDN: URLSearchParams, checked 2026-10-24
- MDN: What is a URL?, checked 2026-10-24
- MDN: Referrer-Policy header, checked 2026-10-24
Questions
What is the difference between a query string and a URL parameter?
The query string is the whole part after the ?. Each key=value pair inside it is one URL parameter, or query parameter.
How long can a query string be?
The standards set no fixed limit, but browsers, servers and apps do. Long tracking URLs can be cut off when pasted into some apps, which is one reason to share a short link instead.
Does the order of parameters matter?
Usually not. Most pages and analytics tools read parameters by name. Some caches and systems treat differently ordered URLs as different addresses, so keep one order in your templates.
Can I put a URL inside a query string?
Yes, but encode it first, so its own ? and & do not break the outer URL. Our URL encoder and decoder does this.
Why did my UTM tags disappear after a redirect?
Some redirects rebuild the destination without the original query string. Check each hop with a redirect checker, and on a short link make sure the tags are in the stored destination or that parameters are passed on.
Try it on your next link
The Free plan includes a custom domain, 5 dynamic QR codes, a bio page and click analytics. No credit card.