Hello Webflow Community,
I’m encountering an issue on my homepage where clicking the “Login” button directs users to https://xxx.abc.tech/?_gl=1*6p3irf*_gcl_au*OTUyNDk1ODcxLjE3Mzg1MjQwNDA
instead of the clean URL https://xxx.abc.tech
. It appears that Google Analytics or Tag Manager dynamically appends these query parameters.
To resolve this, I attempted to implement the following custom code within the <body>
tag:
<script>
(function() {
var url = new URL(window.location.href);
var paramsToRemove = ["_gl", "_gcl_au", "gclid", "utm_source", "utm_medium"];
paramsToRemove.forEach(param => url.searchParams.delete(param));
if (window.location.search !== url.search) {
window.history.replaceState({}, document.title, url.pathname + url.search);
}
})();
</script>
But this code isn't working. Please help.