In short. Carry campaign query parameters into each redirect target, then check the final URL and the page_location value sent to Google Analytics.
Definition: Preserving campaign parameters means carrying the campaign labels in a URL's query string through each redirect to the page where analytics collects them. UTM parameters are Google's campaign labels, such as
utm_source,utm_mediumandutm_campaign; the query string begins after?.
Key facts
- RFC 9110, section 10.2.2 defines
Locationas the response header that identifies a redirect's target. - RFC 3986, section 5.2.2 resolves a target containing a new path using that target's query component, which can be absent.
- As of 17 October 2026, Google's campaign URL documentation describes campaign labels and the Traffic acquisition report's
Session source/mediumandSession campaigndimensions. - Google's configuration reference defines
page_locationas the full page URL, defaulting todocument.locationin the browser.
Why can a redirect remove the query string?
A redirect response supplies a target URL through Location. Under RFC 9110, a relative target is resolved against the requested URL. A relative target can start with /, indicating a path on the same host.
For an illustrative request to /old?utm_source=newsletter1, a response containing Location: /landing resolves to /landing with no query. This follows the path and query resolution algorithm in RFC 3986. An empty reference can inherit the original query, but a new path needs its campaign parameters included explicitly. Each subsequent redirect needs the same check.
What redirect rule preserves the parameters?
As of October 2026, nginx's return directive accepts variables in a redirect URL. The following illustrative configuration belongs inside a server block and redirects /old to /landing:
location = /old {
return 302 /landing$is_args$args;
}
The nginx embedded variables reference defines $args as the request arguments and $is_args as ? when arguments exist, or an empty string otherwise. Together they append the query without adding a question mark to requests that have no arguments. This example assumes /landing has no pre-existing query and no earlier rule changes $args.
The rule carries the whole query string. Its temporary redirect code, 302, is defined in RFC 9110. Campaign preservation comes from the target URL construction.
How can the redirect be tested?
The curl manual documents -L for following redirects, -D for displaying response headers and url_effective for the final fetched URL. With the example rule installed and /landing serving a page, this command checks the chain. The placeholder host represents the configured site.
curl -sS -L -D - -o /dev/null \
-w '\nFinal URL: %{url_effective}\n' \
'https://example.com/old?utm_source=newsletter1&utm_medium=email&utm_campaign=summer-sale'
The expected final URL is:
https://example.com/landing?utm_source=newsletter1&utm_medium=email&utm_campaign=summer-sale
Every intermediate Location needs to retain the campaign values. A second test without a query checks that the destination remains /landing. An encoded value such as email%26promo checks that a value containing an ampersand remains intact; RFC 3986's encoding rules distinguish encoded data from delimiters.
How is analytics collection checked?
Google's campaign collection documentation associates embedded UTM parameters with the document location field, page_location. The browser test therefore checks the URL supplied in the landing page's analytics event, including its query string.
The configuration reference also permits overriding page_location. Comparing that configured value with the final URL helps identify a query removed during collection. After collection and processing, Google's campaign URL guide places session campaign dimensions in Acquisition > Traffic acquisition.
Related terms
FAQ
Can I lowercase campaign values during a redirect?
Google's campaign URL guide says parameter values are case sensitive. Keep the original case when you intend to preserve the same campaign label.
Why does my test retain an earlier session source?
Google's traffic-source documentation says a new campaign encountered during an existing session does not start another session. Test collection separately from session attribution; an existing session keeps its associated campaign or traffic source.
Sources
- IETF, "RFC 9110: HTTP Semantics", June 2022
- IETF, "RFC 3986: Uniform Resource Identifier (URI): Generic Syntax", January 2005
- Google, "URL builders: Collect campaign data with custom URLs", undated
- Google, "Configuration", 5 October 2026
- nginx, "Module ngx_http_rewrite_module", undated
- nginx, "Module ngx_http_core_module", undated
- curl, "curl man page", undated
- Google, "Campaigns and traffic sources", undated
Check how a page reads to answer engines. Open the GEO score analyzer