I was using Google analytics regular expressions on Saturday to try and understand how my cocktail making relationship engine had worked out. As I was using the regular expressions I noticed that there were very few resources to help you get them right for Google Analytics so in case you are interested here are my tips.
First the regular expression variables supported by google analytics:
. match any single character
* match zero or more of the previous items
+ match one or more of the previous items
? match zero or one of the previous items
() remember contents of parenthesis as item
[] match one item in this list
- create a range in a list
| or ^ match to the beginning of the field
$ match to the end of the field
\ escape any of the above
Some real examples:
If you are looking for the page index2.php then your regular expression should be "index2\.php" you want to escape the "." with the / since that will make the regular expression run faster as Google will now only look for the "." character and not "any character" which is the special meaning of ".".
I have a regular expression "displaycocktail.php" within all my cocktail recipe pages. For the test group I was passing ?test=test on the end of that URL to google analytics and for the control group ?test=control. A couple of examples of urls showing up would be:
http://www.cocktailmaking.co.uk/displaycocktail.php/241-Slippery-Nipple?test=test
http://www.cocktailmaking.co.uk/displaycocktail.php/241-Slippery-Nipple?test=control
http://www.cocktailmaking.co.uk/displaycocktail.php/435-Blue-Lagoon?test=test
http://www.cocktailmaking.co.uk/displaycocktail.php/435-Blue-Lagoon?test=control
If I wanted to see just the control group I would use the reg exp "displaycocktail\.php/.*test=control" where the ".*" means match any number of characters at this point in the regexp.
Hopefully this (esp. the working examples) are useful for you to get started.
Comments