In Google Analytics 4 there is no field anymore to exclude query parameters.
To do that, you first have to distinguish between 2 ways of how you set up GA4:
- with gtag.js
- with Google Tag Manager (running a GA4 Tag inside)
JavaScript Code solution from a tutorial
<script>
function cleanPageLocation() {
// define parameters to exclude
var excludeStrings = [
"Go_Away"
];
var addressString = new URL(document.location);
var queryString = addressString.search;
// check if query string holds any parameters, otherwise just return the url without them
if (queryString.indexOf("?") != -1) {
// https://stackoverflow.com/questions/901115/how-can-i-get-query-string-values-in-javascript
var getQueryParamsFromURL = function getQueryParamsFromURL() {
var match,
search = /([^&=]+)=?([^&]*)/g,
decode = function decode(s) {
return decodeURIComponent(s);
},
query = addressString.search.substring(1);
var urlParams = {};
while ((match = search.exec(query))) {
urlParams[decode(match[1])] = decode(match[2]);
}
return urlParams;
};
// create param object from query string
var urlParams = getQueryParamsFromURL();
// if it holds any of the defined parameters, remove the key and keep the rest
Object.keys(urlParams).map(function (key) {
if (excludeStrings.includes(key)) delete urlParams[key];
});
// Create filtered query string
var queryString = new URLSearchParams(urlParams).toString();
// add ? to querystring unless it's empty
if (queryString != "") queryString = "?" + queryString;
}
// return cleaned URL
return addressString.origin + addressString.pathname + queryString;
}
</script>
Apply Code Solution for GA4 gtag.js
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=...your id...">
</script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'YOUR-ID-HERE', {
'page_location': cleanPageLocation(),
});
</script>
Apply code solution for GTM
- In GTM you use the code solution in a JS Variable
- Then in the GA4 configuration tag, you add the field
page_location
and give it as value the JS Variable

https://bluerivermountains.com/en/ga4-query-parameter-exclusion