Query String
Definition
The query string runs from the first question mark to either a hash or the end of the address. It holds parameters as name-and-value pairs joined by ampersands, so a string containing utm_source=email and ref=deck carries two of them. Values have to be percent-encoded, so a space becomes %20 or a plus sign depending on the convention in use, and an ampersand inside a value must be written as %26 or it will be read as a separator. Unlike the fragment, the query string travels to the server as part of the request, so it appears in access logs and analytics. On a dynamic site an application reads it; on a static host nothing on the server reads it at all, and only JavaScript in the page can act on it.
Why It Matters
Campaign tracking lives in the query string, so losing it loses your attribution. Paste a link carrying utm_source into certain chat clients or shorteners and the parameters are stripped; the visit then arrives looking like direct traffic and the campaign appears to have done nothing. Caching is the other consequence — many CDNs treat two addresses that differ only by query string as two separate objects, so careless parameters fragment the cache and slow everything down. And since the string shows up in logs, referrer headers and browser history, it is the wrong place for anything you would not want repeated.
How It Works
When you open an address, the browser puts the path and the query string into the HTTP request line and sends them together. A server-side application parses the pairs and decides what to do with them. A static host does not: it looks for a file matching the path and ignores everything after the question mark, so plan.pdf with a version parameter and plain plan.pdf return the same bytes. That is still useful, because the string does reach the edge logs, so analytics can attribute the visit even though the content never varies. Client-side code can read the pairs as well, which is how a single page can respond to a parameter without any server logic behind it.
Real-World Example
A studio publishes a capability deck at foundry-deck.99helpers.site and sends it three ways, appending a different source parameter each time for email, LinkedIn and a printed QR code. The file served is identical in all three cases. The analytics panel shows 210 opens from email and 38 from LinkedIn, so next quarter's effort goes where the opens are. Nothing on the host needed configuring; the parameter simply rode along with the request.
Common Mistakes
- ✕Putting a token or an email address in a query string — it lands in server logs, browser history and the referrer header sent on to third parties
- ✕Expecting a static host to act on a parameter — the same file comes back either way, because no application is reading it
- ✕Forgetting to encode a value that contains an ampersand or a hash — the address silently truncates at that character and the rest is lost
Related Terms
URL Anatomy
URL anatomy is the set of parts a web address is built from: scheme, host, path, query string and fragment. Knowing which part is which explains most link problems in seconds.
UTM Parameter
A tag added to the end of a URL to record where a visit came from. Analytics tools read the tag and group the visit under the campaign you named.
URL Encoding
URL encoding replaces characters that are unsafe or reserved in a web address with a percent sign and two hex digits, so a space becomes %20. It is why a filename with spaces or accents can break a link.
URL Fragment
A URL fragment is the part after the hash, such as a section name or a page number. It tells the browser where to scroll or what to show, and it is never sent to the server.
Cache-Control
The HTTP response header that tells browsers and caches whether they may keep a copy of a file, for how long, and who is allowed to. It is the single biggest lever over how fast a site feels on a second visit.
Put a file online in seconds
Drop in a document, an image, a page or a whole static website and share the link — free, with no build step and no server to set up.
Host a file free →