Google Analytics URL regex code

1.4k Views Asked by At

I am setting goal conversion for my site links which are dynamic in Google Analytics

https://www.learningandthebrain.com/Online-Register/CONF-103/Submit

example of the dynamic links is above here the number after CONF- keeps changing and I want to create final URL for my goal

I have to enter the regexp expression to match the site link Online-Register/CONF-103/Submit

3

There are 3 best solutions below

0
On

If only the number after CONF changes, something like this should do the trick:

(.*)learningandthebrain\.com/Online-Register/CONF-(\d+)/Submit

This is pretty much as basic as it gets, so I would advice you to look into regular expressions in your free time. When learning regular expressions I have found this tool indispensable: http://gskinner.com/RegExr/ - it allows you to easily check if your regex works as expected.

Edit: The regex should not include the www part of the domain, because then it will only match requests coming from it and ignore requests from http://learningandthebrain.com. Actually I am pretty sure that even the "catch all" (.*) expression at the beginning can be omitted.

Also, forward slash escaping is not required with google analytics.

0
On

Just for the sake of efficiency finish Crafty_Shadow's regex

https:\/\/www\.learningandthebrain.com\/Online-Register\/CONF-(\d+)\/Submit

(I know this would better be a comment but I still don't have the rank to do it)

0
On

You should use the following regex:

/Online-Register/CONF-(\d+)/Submit

Note that the domain is not part of the Page attribute and won;t match if you include it in the regex. Just include the path.

I'd also enable the ignore case flag if you are using a webserver that makes no distinction between uppercase and lowercase like IIS.