// Remove tracking utm query // Convert the iterator to an array to avoid modification issues let keys = Array.from(ctx.url.searchParams.keys()); // Loop through all parameters keys.forEach(function(key) { // Check for both utm with and without underscore, same for uta if (key === "utm" || key.startsWith("utm_") || key === "uta" || key.startsWith("uta_")) { ctx.url.searchParams.delete(key); } }); // If needed: Apply the changes to the current URL // window.history.replaceState(null, '', ctx.url.toString());