UTMs or gclid lost in a redirect: how to test and fix it
Published by the UTM Builder team at Limner.
When the ad URL goes through a redirect that doesn’t pass the query string along, the final page opens without UTMs or gclid, and GA4 records the visit as (direct) / (none). To test it, open the real link and look at each hop. The fix is usually a rule in the server, the plugin or the URL shortener.
Where the UTM gets lost
GA4’s help page on direct traffic lists redirects from one site to another or from https to http, and URL shorteners such as bit.ly, among the things that can strip parameters. The usual suspects:
- Server rules. http to https, non-www to www, old URL to new URL, trailing slash. Each rule is a hop, and it only takes one of them dropping the query string.
- WordPress redirect plugins. A rule created for the clean URL may not handle the URL with parameters the way you expect.
- URL shorteners. The short link points to the URL you pasted when you created it. If you pasted it without UTMs, there are no UTMs to arrive.
- Link-in-bio pages. The UTM on the bio link stays on the intermediate page. The visit to your site comes from the button, and what counts is that button’s URL.
- In-app browsers. Many apps open links inside the app. The real click goes through there, so testing in Chrome on your computer isn’t enough.
The gclid alert in Google Ads
Google Ads has its own alert for this: "Website redirects are losing click data". The help page explains that it appears when redirects don’t pass the GCLID along and that, without it, the click isn’t associated with any future conversion. The auto-tagging page says the same: if your site uses redirects, the GCLID has to reach the final landing page.
The same page covers sites that return an error when they receive parameters: turn off auto-tagging, ask your developer to allow arbitrary URL parameters, and only then turn it back on.
How to test
- Copy the link exactly as it is in the ad, the bio or the email. For Google Ads, add
gclid=teste123to the final URL, with?or&as needed. - In Chrome, open DevTools, go to the Network panel and check Preserve log, which keeps requests across page loads.
- Open the link. Click each 301, 302, 307 or 308 response and look for the
Locationheader under Response Headers. The parameters have to be there at every hop. - On the final page, check the address bar and see whether the visit shows up in GA4’s Realtime report.
- Repeat on your phone and inside the app where the link will be shared.
http://loja.com.br/promo?utm_source=teste&utm_medium=teste&utm_campaign=teste-redirect&gclid=teste123
Start with http:// and no www on purpose: that way the test goes through the hops the server adds on its own.
How to fix it
- Link straight to the final URL. The quickest fix is to put the final URL in the ad, already on https and on the right domain. No hop, nothing to lose.
- Apache. The
Redirectdirective carries GET parameters over to the target, according to the documentation. WithRewriteRule, if the target has no query string, the original one is copied; if the target has its own, the original is discarded unless the rule uses[QSA]. The[QSD]flag discards the query string on purpose. Look for rules withQSDor with?in the target. - Nginx. The
$request_urivariable is the full original URI, arguments included. Inrewrite, a?at the end of the replacement stops the old arguments from being appended: that question mark is what wipes out the UTM. - WordPress with the Redirection plugin. The documentation lists three options for query parameters. The default is "Match query parameters exactly". For the UTM to reach the target, use "Ignore and pass parameters to the target":
/promo?utm_source=xgoes to/oferta?utm_source=x. - URL shortener. Create the short link pointing to the long URL that already has the UTMs. If you want to add parameters to the short link and have them reach the destination, check the shortener’s documentation to see whether it passes them along and on which plan.
nginx: return 301 https://www.loja.com.br$request_uri;
apache: RewriteRule "^promo$" "/oferta?ref=site" [R=301,L,QSA]
Official sources
- Google Analytics: Understand "(direct)" / "(none)" traffic
- Google Ads: Troubleshoot: Website redirects are losing click data
- Google Ads: About auto-tagging
- Chrome DevTools: Network features reference
- Apache HTTP Server: mod_alias (Redirect)
- Apache HTTP Server: RewriteRule Flags (QSA and QSD)
- nginx: ngx_http_rewrite_module
- nginx: ngx_http_core_module ($request_uri)
- Redirection (WordPress): Matching a URL