简体   繁体   中英

Google Analytics URL regex code

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

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.

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)

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM