UTM parameters lost after redirect: causes and fixes
By Devendra Variya, co-founder of Virling. Published 2026-11-19, updated 2026-12-01.
When UTM parameters are lost after a redirect, the usual cause is a server rule that builds the new address from the path alone and throws away the query string. The http to https, www to bare domain and trailing slash redirects are the first places to look. To test it, run curl -sIL "http://example.com/pricing?utm_source=test" and read every Location header: if utm_source=test is missing from one of them, that hop is the culprit. The visit then arrives untagged and lands in Direct or under the wrong referrer.
Check the whole path first
Your analytics only sees the tags that are in the address bar when its script runs. Anything between the click and that moment can remove them: a shortener, one or more server redirects, a consent or login page, or your own front-end router. A privacy feature can also remove tracking information from the link itself; what Apple documents about that is in iOS Link Tracking Protection and UTM parameters. Start by pasting the link into the UTM checker to rule out mistakes in the link itself, such as tags after the # or a duplicate parameter. Then follow the hops below in order. If it is the referrer that goes missing instead, see why document.referrer is empty.
curl -sIL "http://example.com/pricing?utm_source=test&utm_medium=email" | grep -i '^location'
Each line is one hop. Every one of them should still carry the full query string.
Cause 1: server redirects that drop the query string
Redirects from http to https, from www to the bare domain (or the reverse) and from /pricing/ to /pricing are often written by hand, and it is easy to use a variable that holds only the path.
Check: request each variant of your address with a tag and look at the Location header.
curl -sI "http://example.com/?utm_source=test" | grep -i '^location' curl -sI "https://www.example.com/?utm_source=test" | grep -i '^location' curl -sI "https://example.com/pricing/?utm_source=test" | grep -i '^location'
Fix in Nginx: $request_uri holds the path and the query string, $uri holds only the path. A rewrite keeps the query string unless the replacement ends in ?.
# Drops the tags
return 301 https://example.com$uri;
# Keeps the tags
server {
listen 80;
server_name example.com www.example.com;
return 301 https://example.com$request_uri;
}
server {
listen 443 ssl;
server_name www.example.com;
return 301 https://example.com$request_uri;
}
# Trailing slash: rewrite adds the original query string back
rewrite ^/(.+)/$ /$1 permanent;
Fix in Caddy: the automatic http to https redirect keeps the query string. In your own redir, {uri} holds the path and the query string, {path} holds only the path.
# Drops the tags
redir https://example.com{path} permanent
# Keeps the tags
www.example.com {
redir https://example.com{uri} permanent
}
The same rule applies to redirects set up in a hosting dashboard or a CMS plugin: look for an option to forward the query string, and test the result with curl.
Cause 2: link shorteners
A shortener is one more redirect. Some keep the tags that were part of the destination you shortened but ignore tags added to the short link afterwards, and some redirect through a page of their own first.
Check: curl -sIL https://short.link/abc | grep -i '^location' and confirm the last hop has your tags.
Fix: build the tagged destination first with the UTM builder, then shorten that full URL. Do not add tags to the short link itself. If the page URL already carries old tags or click IDs, strip them first with the URL cleaner.
Cause 3: consent and login walls
A page that sends visitors to /login?next=/pricing or reloads after a cookie banner often keeps the path and forgets the rest. If your analytics only loads after consent, the tagged landing page may be gone by the time the script runs.
Check: open the tagged link in a private window, go through the banner or the login, and watch the address bar at each step.
Fix: pass the full path and query string into the return address, URL-encoded, for example /login?next=%2Fpricing%3Futm_source%3Dtest, and send the visitor back to it after sign-in. If the banner reloads the page, reload the current location.href, not the bare path.
Cause 4: single-page app routers
In a single-page app nothing reaches the server after the first load, but the router can still rewrite the address. A redirect from / to /home, a locale prefix, or code that tidies the URL with history.replaceState will drop the tags if it only passes the path. If that runs before your analytics script reads the address, the tags are lost.
Check: open the tagged link and, before clicking anything, run location.search in the browser console. It should still show the tags.
Fix: carry location.search into every router redirect, and do not strip tags from the URL in code. Load the analytics script in the root layout so it reads the landing address. The Virling script reads UTM tags from the landing URL and follows route changes through the History API; see single-page app tracking. For the checkout side, see Angular Stripe UTM tracking and Vue Stripe UTM tracking.
Cause 5: checkout on another domain
Tags do not follow a buyer from your site to checkout.stripe.com, a hosted Paddle checkout or a store on another domain, and they do not need to. Your analytics script reads the tags on the landing page. If your own server needs them later, see how to persist UTM parameters across pages. What gets lost at checkout is the link between the payment and that visit, so the sale shows up as Direct or unattributed.
Check: open your site from a tagged link, pay in your provider's test mode, and see which source the sale gets.
Fix: pass the visitor ID into checkout instead of trying to forward UTM tags. The steps for each provider are in cross-domain checkout attribution. A checkout shown inside an installed app carries no visitor ID at all; selling a desktop app through Paddle explains which purchases can be linked.
Do not tag your own internal links
A last trap looks like the opposite problem. Adding UTM tags to links between your own pages overwrites the source the visitor arrived with. In Virling, a page that loads with different UTM tags starts a new session. Tag links that point to your site from somewhere else, and leave internal links plain. The same goes for a link that your browser extension opens on your own site; attributing browser extension sales shows why.
Quick reference: which redirects keep the tags
The causes above in one table. Paste your tagged link into the UTM checker first, then follow each hop it passes through and find it in the rows below.
| Redirect | Do the tags survive? | Fix |
|---|---|---|
| 301 that keeps the query string | Yes. Nginx return 301 with $request_uri, Caddy redir with {uri} and Caddy's automatic http to https redirect all pass the tags on. | Nothing to fix. Confirm with curl -sIL that every Location header has them. |
| 301 that drops the query string | No. A rule built from $uri in Nginx or {path} in Caddy sends the path alone. | Use $request_uri or {uri}. In a hosting dashboard or CMS plugin, turn on forwarding the query string. |
| Link shortener | Usually, if the tags were on the destination you shortened. Tags added to the short link itself may be dropped. | Build the tagged URL with the UTM builder, then shorten the full URL. |
| Consent or login wall | Often not. The return address or the reload after the banner keeps the path and forgets the query string. | Put the URL-encoded path and query string in the return address, and reload location.href, not the bare path. |
| Single-page app router | Not if a route redirect or history.replaceState passes only the path before the analytics script reads the address. | Carry location.search into every router redirect and load the script in the root layout. |
| Checkout on another domain | No, and they do not need to. The tags were read on the landing page. | Pass the visitor ID into checkout so the payment joins the tagged visit. |
Setup checklist
- Build each campaign link with the UTM builder and check it with the UTM checker
- Run
curl -sILon the link and on the http and www variants, and confirm every hop keeps the query string - Open the link in a private window and confirm
location.searchstill has the tags after any banner, login or router redirect - Pass the visitor ID into checkout and make a test purchase
- Confirm the test visit and the test sale show the source you tagged, not Direct
Virling reads utm_source, utm_medium, utm_campaign, utm_content and utm_term from the landing URL, and falls back to ref when utm_source is missing. It joins each payment to the visit before it, so once the tags arrive you see revenue by source and campaign, not only visits.
Frequently asked questions
Why are my UTM parameters lost after a redirect?
Usually because a server redirect builds the new address from the path alone and drops the query string. Http to https, www to bare domain and trailing slash rules are the usual suspects. Run curl -sIL on a tagged link and check that every Location header still has the utm_ tags.
Why are my UTM parameters not passing to my analytics?
Either a redirect dropped them before the page loaded, or the page removed them before the analytics script read them. Single-page app routers and consent or login redirects can do the second. Open the tagged link in a private window and watch the address bar.
Do 301 redirects keep the query string?
A 301 keeps whatever the server puts in the Location header. In Nginx, $request_uri keeps the query string and $uri does not. In Caddy, {uri} keeps it and {path} does not.
Do link shorteners strip UTM parameters?
Most keep the tags that are part of the destination you shortened, but some drop tags you add to the short link itself. Put the tags on the destination before you shorten it, and check the short link with curl -I.
Do UTM parameters survive a checkout on another domain?
They do not need to. Your analytics reads the tags on the landing page. To keep the source of a sale, pass the visitor ID into checkout so the payment joins to the tagged visit.
See the revenue behind every tagged link
Virling is open source under AGPL. Self-host it free, or use the hosted version with a 14-day free trial. It connects to Stripe, Paddle, Shopify, WooCommerce, Polar, LemonSqueezy, Dodo, Creem and RevenueCat.