Why HTTP Redirects Strip UTM Parameters (and How to Preserve Query Strings)

Learn how HTTP 301 and 302 redirect rules can affect UTM parameters and campaign reporting, and how to inspect query-string handling on your server.

Technical diagram showing how an HTTP 301 redirect strips query parameters vs preserving them with QSA
Table of Contents
  1. The Mechanics of Parameter Loss During Redirects
  2. Server Configuration Fixes: Nginx, Apache & Cloudflare
  3. The Trailing Slash Trap
  4. How to Test Redirect Chains via CLI and UTMCraft

A redirect can drop UTM parameters if the destination leaves out the incoming query string. Follow the link through each redirect and check the final landing URL. The examples below show how to inspect and preserve campaign parameters.

The Mechanics of Parameter Loss During Redirects

When a browser requests a URL like https://example.com/signup?utm_source=google, the server may issue an HTTP 301 redirect to normalize the URL (e.g. enforce HTTPS, www, or trailing slash). If the server rule is written as:

# INCORRECT NGINX CONFIGURATION (Drops query string)
return 301 https://example.com/signup/;

If the redirect target omits the incoming query string, the browser may reach https://example.com/signup/ without those parameters. If no other clear referral or campaign information is available, GA4 may report the visit as (direct) / (none). Check the final URL and the data received by the analytics tag.

Server Configuration Fixes: Nginx, Apache & Cloudflare

1. Nginx Query String Preservation

A Nginx rewrite to a path can preserve the query string automatically. A manual return needs it included in the destination when retention is intended. Apply redirects in the appropriate location and test for loops; the trailing-slash example below matches only the non-slash path.

# CORRECT NGINX REDIRECT
rewrite ^/signup$ /signup/ permanent; # Automatically preserves query string
# Or for manual returns:
return 301 https://example.com/signup/$is_args$args;

2. Apache mod_rewrite and the [QSA] flag

In Apache .htaccess, [QSA] (Query String Append) is an Apache-specific flag. It is relevant when the rewrite substitution creates a query string and you also need to append the incoming one; it is not a universal requirement for redirects:

# CORRECT APACHE HTACCESS RULE
RewriteEngine On
RewriteRule ^signup$ /signup/ [R=301,L]

3. Cloudflare Redirect Rules

For Cloudflare Single Redirects, enable Preserve query string when the destination should retain incoming campaign values. Test the resulting Location header and final URL. See Cloudflare’s redirect settings.

The Trailing Slash Trap

A trailing-slash redirect is one possible cause. If a site redirects https://example.com/pricing?utm_source=meta to /pricing/, inspect the response to see whether it preserves the query string. Matching your site's canonical URL format can avoid an unnecessary hop, but verify the final destination either way.

How to Test Redirect Chains via CLI and UTMCraft

Use curl in your terminal to inspect redirect hops:

curl -sS -L -D - -o /dev/null "https://yourdomain.com/landing?utm_source=test"

Verify that every Location: response header retains ?utm_source=test until the final successful response. This uses GET; a server’s HEAD behavior can differ.

For the broader setup, read GA4 UTM Tracking Troubleshooting Guide: Root Causes, Debugging & Solutions. Browse the GA4 Attribution & Troubleshooting guides to choose another troubleshooting task.

References