On this page
What this issue is
A query string is the part of a URL after the ?, for example ?utm_source=google&utm_medium=cpc&gclid=abc123. UTMs are tags you add to say where a visitor came from. gclid is a click ID that Google Ads adds when auto-tagging is on. Meta uses fbclid and Microsoft uses msclkid in the same way.
- Ad clickURL has ?utm_source=google&gclid=abc123
- Redirect301 to the new URL without the query string
- Landing pageLoads on a clean URL
- Analytics and ad tagsNo source, medium or gclid to read
- ConversionCounted as direct, not credited to the ad
The redirect is the break. Everything after it works, but without attribution data.
Why it costs you leads or sales
Example: 100 real conversions from one ad campaign. With a redirect that drops the query string, most are reported as direct.
How to check if your site has it
Build a test URL
Take the exact URL your ad uses and add
?utm_source=test&utm_medium=cpc&gclid=test123. Use the same variations real visitors may hit: http, non-www, a trailing slash missing, and any old URL.Open it in a browser
Paste it in the address bar and wait for the page to load.
Compare the final address
If the address bar no longer shows
utm_sourceandgclid, a redirect dropped them.Find which hop dropped them
Run
curl -sILon the URL and read eachlocation:header. The hop where the query string disappears is the rule to fix.
curl -sIL "http://example.com/landing?utm_source=test&gclid=test123" | grep -iE '^(HTTP|location)'How to fix it
Check your redirect plugin
In Redirection, Rank Math or Yoast Premium, open the rule and look for a setting such as 'Pass-through query parameters' or 'Ignore query parameters and pass them to target'. Turn it on.
Check the https and www settings
If a security or caching plugin forces https or www, test it with a tagged URL. Replace any custom rule that ends the target with a bare URL.
Review URL redirects
Go to Online Store, Navigation, View URL redirects. Shopify normally carries query strings through to the target, but check the target field does not already contain a
?.Update ad final URLs
If an old path redirects, change the ad final URL to the new path so the click needs no redirect.
Do not rely on GTM for the redirect
GTM runs after the page loads, so it cannot recover tags lost in a redirect. Fix the redirect itself.
Check any redirect tags
If a Custom HTML tag sets
window.location, change it to includewindow.location.search, as in the code below.
Open 301 redirects
Go to Site settings, Publishing, 301 redirects. Webflow redirects do not always carry the query string over, so test each rule with a tagged URL.
Remove the redirect from the ad path
Point ads at the final page URL. If a redirect must stay, set up the rule at the proxy or CDN in front of the site and keep the query string there.
Check funnel and domain redirects
In Sites, check the funnel step paths and any URL redirects under Settings. Use the final funnel URL in ads.
Test the custom domain
Open the tagged URL on your custom domain with and without www and confirm the tags remain.
Review the Redirect Manager
Go to Settings, SEO, URL Redirect Manager. Test each old path with a tagged URL. If tags are lost, set the ad final URL to the new page.
Review URL mappings
Go to Settings, Developer Tools, URL Mappings. Test each rule with a tagged URL.
Avoid redirecting ad landing pages
If a mapping drops tags, point ads at the destination page instead.
Apache (.htaccess)
Use
QSAor leave the target without a?. A bare target keeps the original query string, but adding?to the target removes it.Nginx
Use
return 301 https://example.com$request_uri;which includes the query string. Do not use$uri, which drops it.
server {
listen 80;
server_name example.com www.example.com;
# $request_uri includes the path and the query string
return 301 https://example.com$request_uri;
}RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R=301,L,QSA]window.location.replace('/new-page' + window.location.search + window.location.hash);Query string dropped
- /old?utm_source=google&gclid=abc becomes /new
- GA4 records direct traffic
- Google Ads cannot match the click to the conversion
Query string kept
- /old?utm_source=google&gclid=abc becomes /new?utm_source=google&gclid=abc
- GA4 records google / cpc
- Google Ads can match the click to the conversion
How to confirm it's fixed
- A tagged URL ends on the final page with utm_source and gclid still in the address bar
- The curl test shows the query string in every Location header
- http, www and non-www versions all behave the same
- GA4 Realtime or DebugView shows the test source, not direct
- Ad final URLs point at the final page with no redirect
How to prevent it happening again
- Test a tagged URL after every redirect, domain or hosting change
- Keep one redirect hop at most between an ad click and the page
- Update ad final URLs when pages move, rather than relying on redirects
- Write redirect rules with the query string passed through by default
- Review the direct traffic share in GA4 after releases
How FunnelGuard handles this
Questions people ask
Why are my UTM parameters missing in GA4?
A common cause is a redirect that drops the query string before GA4 loads. Open your tagged URL and check whether utm_source is still in the address bar after the page loads. If not, fix the redirect rule so it passes the query string through.
Why is my gclid not showing on the landing page?
Either auto-tagging is off in Google Ads, or a redirect removed the gclid. Check that auto-tagging is on, then test your ad URL for redirects with curl or a browser. Make the redirect keep the query string or point the ad at the final URL.
Does a 301 redirect keep query strings?
It depends on how the rule is written. A 301 only tells the browser where to go, and the target URL decides whether parameters are included. Some servers and plugins pass them by default, others drop them, so always test.
How do I keep UTM parameters in an htaccess redirect?
Add the QSA flag to the RewriteRule, for example [R=301,L,QSA], and do not end the target with a ?. Then test with a tagged URL. A trailing ? on the target removes the original query string.
How do I keep the query string in an Nginx redirect?
Use return 301 https://example.com$request_uri;. The $request_uri variable includes the path and the query string, while $uri does not.
Why does my ad traffic show as direct in analytics?
One cause is that tracking parameters were lost before analytics could read them, often because of a redirect. Other causes are missing UTMs and some privacy or app-based clicks. Test your ad URLs end to end to rule out the redirect.
Can Google Tag Manager fix parameters lost in a redirect?
No. GTM runs after the final page loads, so it cannot recover parameters the redirect already removed. The fix has to be in the redirect rule or in the ad URL.
How can I monitor for lost UTMs automatically?
Use a synthetic monitor that opens a tagged URL on a schedule and compares the parameters after redirects. FunnelGuard does this with its UTM persistence check and alerts you when they disappear.
Related issues
- SEO-083http not redirecting to httpsFix guide
- SEO-084Redirect ends on the wrong page (home instead of product)Fix guide
- SEO-085302 temporary redirects used for permanent movesFix guide
- SEO-086Meta refresh or JavaScript redirects instead of 301Fix guide
- SEO-081Redirect chains of 3+ hopsFix guide
- SEO-089Internal links point to redirecting URLsFix guide