I use Google Analytics to track the searches users do on my website. I have no query parameter for searches (nothing like q=mykeyword
).
Therefore I use Google Tag Manager to send a "fake" value for the field page
to Google Analytics with the following snippet:
function() {
var regex = /^(\/[a-z]{0,2}\/live\/search)\/(.*)/;
if(regex.test({{Page Path}})) {
var res = regex.exec({{Page Path}});
return res[1]+"?gaSearchLive=" + res[2];
}
return;
}
A typical URI used for searches is /de/live/search/mykeyword?searchID=1234
or /en/archive/search/mykeyword2?searchID=4567
.
My website differentiates between live
and archive
searches. Is there a way to separate those two kinds of search in a way that I can analyze them separately in Google Analytics?
How can I prevent query parameters from polluting my analysis?
In section Behavior => Site Search => Pages
I see the following:
Is there a way to remove parameters like "searchID" / "page" etc. from the url? How do I need to modify my Google Tag Manager tag? Is it possible to overwrite the url sent to Google Analytics as I do already for the page
field?