13.07.2015 Views

ebook on regular expressions for Google Analytics - LunaMetrics

ebook on regular expressions for Google Analytics - LunaMetrics

ebook on regular expressions for Google Analytics - LunaMetrics

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

anchorsThE d oLLar siGnA dollar sign means d<strong>on</strong>’t match if the target string has anycharacters bey<strong>on</strong>d where I have placed the dollar sign in myRegular Expressi<strong>on</strong>.So let’s say you want to include your homepage in your funnel.(Not such a great idea, if you ask me, but this book is about RegExand not best analysis practices.) <strong>Google</strong> <strong>Analytics</strong>, by default, callsyour homepage this:$/i.e., just a slash. The problem with including just a slash in yourfunnel is that it will match everything. Every single URL <strong>on</strong> yoursite has a slash in it, so it automatically matches them all, sinceRegEx are greedy. In order to match just your homepage, youshould follow it with a dollar-sign anchor, like so:/$That means the page has to end with a slash.But wait … aren’t there pages that end with a slash that aren’t yourhome page? Like so: /mysite.com/folder/So the very best way you can be sure to get just the slash page(homepage) is with a beginning and an ending anchor:^/$Use this cautiously, because you might havequery parameters that are “shut out” of thematch. For example, let’s say your affiliatemarketers append code <strong>on</strong>ly to the end of theURL, so they can get credit <strong>for</strong> the sale:http://www.mysite.com/productpage123?affiliate=storenameIn the eyes of <strong>Google</strong> <strong>Analytics</strong>, that looks like:/?affiliate=storename… and it doesn’t match the ^/$ RegEx in theexample <strong>on</strong> this page, because the target stringdoesn’t start and end with the same slash.20

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!