I've been trying to get a GA regex filter to alias a custom query paramater as utm_campaign
. For example, we have this url:
https://example.com?open=1&sid=123456
In order to track sid
as utm_campaign
, I've created a "Search and Replace" filter, with the following regex:
Search String:
(\?|&)sid=
Replace:
$1utm_campaign=
This is valid Regex, and works in Regexr. However it's not rewriting the parameter in GA.
Does anyone know of any reason this wouldn't work? Are their exceptions to what regex can be used? I can't seem to find any mention of this in the docs.
Also, does anyone know whether this would actually be recorded as a utm_campaign
param? If I change a non-default param to be utm_campaign
, does GA correctly recognise this?
Many thanks for any help in advace.
After some more investigation, it seems like Darrellwan is correct, the utm_campaign
params are recognised by GA prior to filters being applied, which is a shame!
To answer the regex question, I ended up doing this:
As is mentioned in another answer, GA uses $A1
/ $B1
etc to handle regex match / replace in the advanced section.
Just in case anyone else is looking for an answer to this.
It looks like we'll need another solution to our sid
param issue though.
Thanks again for the help!