Money back guarantee
From $0.07 per 1 000 credits

How to Exclude URL Query Parameters in GA4 Without Losing Attribution

To exclude URL query parameters from a GA4 page report, start by changing the reporting dimension to Page path and screen class. It groups query-string variants under the same path without changing the URL GA4 collects or removing campaign information.

If you remember the Exclude URL Query Parameters box under a Universal Analytics view, GA4 doesn’t have that view setting. Start with the report instead. Selectively removing parameters from measurement and preventing personal information from reaching Google are different jobs. Before changing your tags, decide which one you need. And if a parameter identifies the product, language, or content someone sees, don't merge it away without keeping that distinction elsewhere.

Hypothetical GA4 example groups pricing-page URL variants with 50, 30 and 20 views into a single /pricing row with 100 views using Page path and screen class, while keeping the source query strings intact.

Group URL variants in a usable GA4 report

Say your pricing page appears as /pricing, /pricing?fbclid=example-a, and /pricing?fbclid=example-b. In a hypothetical example, those variants have 50, 30, and 20 views. You want one /pricing row with 100 views, rather than three rows that make the page look less popular.

Open Reports > Engagement > Pages and screens (or search for Pages and screens if your report collections use a different layout) and select Page path and screen class from the table's primary-dimension dropdown. Google's Pages and screens documentation identifies this as the page-path dimension. Unlike Page location, it doesn't include the query string.

If you want a saved workspace for comparing the grouped result with the detailed URLs, build a free-form exploration:

  1. Open Explore > Free form, name the exploration “Pages without query strings,” and set your date range.
  2. Import Page path and screen class, Page path + query string, Page location, and Hostname as dimensions.
  3. Import Views and Active users as metrics.
  4. Put Page path and screen class in Rows and the metrics in Values. If the property covers several domains, filter Hostname to the site you're reviewing.
  5. Duplicate the tab and replace the row dimension with Page path + query string to inspect the remaining variants. Use Page location when you need the full collected URL.

Keep query-bearing dimensions out of the grouped tab's rows and columns. Adding them back splits the rows again.

This is aggregation, not deletion. It can group available historical data without rewriting it. Views add across the variants, but distinct users don’t: one person can visit several versions. This report also covers all page visits, not just session entrances.

Keep campaign tags available for attribution

A clean page row should still let you credit the newsletter or ad that brought someone there. Removing campaign tags before measurement can sacrifice that information just to shorten a report.

For campaigns you manage, website traffic platform SparkTraffic offers a free UTM builder that creates a consistent link for the attribution check below. Use a clearly labeled test campaign rather than changing a live campaign's tags.

Keep utm_source, utm_medium, and utm_campaign available when the Google tag processes the arrival. Preserve measurement keys such as gclid and the cross-domain linker _gl too. Google's cross-domain guidance explains why losing _gl can break continuity between domains.

There's a useful GA4 detail here: Google's campaign URL documentation says UTM parameters are already omitted from Page path + query string and Landing page + query string. They remain in Page location, while campaign values populate acquisition dimensions.

So missing UTM text in a page-path report isn't evidence of lost attribution. Check Session source / medium and Session campaign in Traffic acquisition. Don't strip every parameter because a full-URL report looks crowded.

Normalize selectively when parameters change the page

A query-free path can merge genuinely different content. Consider these hypothetical product URLs:

/product?id=123&lang=en&fbclid=example-a
/product?id=123&lang=en&fbclid=example-b
/product?id=456&lang=fr&fbclid=example-c

Grouping everything as /product hides which product and language people viewed. A useful normalized reporting field would combine the first two URLs as /product?id=123&lang=en and keep the third separate.

Write down the rule before implementing it. Here, id identifies content, lang identifies its language, and fbclid is excluded only from the derived reporting field. On another site, pagination, search terms, or filter selections may also explain meaningful differences. A rule that removes everything after ? can't make those decisions for you.

The safer implementation is a separate reporting value, leaving the collected page_location untouched except for required privacy protection. For this product detail page, use an allowlist rather than copying every key except the tracking IDs you know about. This GTM Custom JavaScript variable keeps only a numeric catalog ID of up to eight digits and one of three supported languages:

function() {
var url = new URL(window.location.href);
var kept = new URLSearchParams();
var id = url.searchParams.get('id');
var lang = url.searchParams.get('lang');
if (id && /^[0-9]{1,8}$/.test(id)) kept.set('id', id);
if (lang && /^(en|fr|es)$/.test(lang)) kept.set('lang', lang);
var query = kept.toString();
return url.pathname + (query ? '?' + query : '');
}

Use that rule only on an audited route such as /product; never send a raw path that can contain account details. Make sure id is a public catalog ID, not a customer ID. Query-parameter redaction doesn't automatically sanitize arbitrary custom fields. Send the approved result as reporting_path on the relevant page-view events, then register it under Admin > Data display > Custom definitions, with Event scope and reporting_path as the event parameter. Google's custom-dimension instructions explain the setup and why the new dimension usually takes 24 to 48 hours to appear.

Build another exploration with that custom dimension in Rows and Views in Values. Standard GA4 custom parameter values have a 100-character limit. If meaningful combinations produce long URLs or too many unique rows, collect controlled fields such as product ID and language instead.

If you must normalize page_location itself before collection, treat that as a tagging change. Apply it before the first affected event and consistently across later events, including single-page-app navigation. Google's pageview documentation requires a full URL, including the protocol, when overriding this field. Adding a second page-view tag to send a cleaner URL can double-count views.

Redact personal information before it reaches Analytics

An email address in a URL is a privacy issue even when your report hides the query string. The full value may still have been collected. Google's PII guidance requires both URL paths and parameters to be free of personally identifiable information.

For a web stream, configure GA4 data redaction:

  1. With Editor access or above, open Admin > Data collection and modification > Data streams and select the web stream.
  2. In the Events section, select Redact data.
  3. Enable email redaction and URL query-parameter redaction as needed. Enter the actual parameter names that carry sensitive values, pressing Enter after each.
  4. Use Test data redaction and Preview redacted data with dummy values.

For example, a hypothetical ?email_address=reader@example.com becomes ?email_address=(redacted). The key remains. Redaction masks values before collection; it isn't the same as removing query keys for reporting.

Email detection is best effort. This feature doesn't protect Measurement Protocol submissions or Data Import, and enabling it doesn't clean previously collected data. Fix the application that exposes personal information in URLs, review other outgoing event fields, and handle server-sent data separately. A tidy report isn't proof of a privacy-safe implementation.

Test aggregation and attribution separately

Before publishing a tagging change, use a test property or controlled QA visit with the appropriate consent settings. Open a tagged link in a fresh test session, inspect page_location and any derived reporting parameter in GTM preview and GA4 DebugView, and check the processed acquisition report afterward.

The acceptance checks are specific: equivalent URLs share a reporting row, meaningful product or language variants stay distinguishable, the expected campaign receives credit, and dummy sensitive values are absent from outgoing Analytics data. Confirm that page views aren't duplicated.

If your only change was choosing a query-free dimension, collection should remain unchanged. Keep that grouped report alongside the detailed diagnostic tab. You get a readable page total without giving up the evidence needed to explain it.

SparkTraffic

Website traffic and analytics guides from SparkTraffic.

Content on this site is openly accessible for indexing and use by AI systems and LLMs (e.g., ChatGPT, Gemini, Claude, Perplexity, etc.).
We support transparency and innovation in AI. 🤖