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

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

wildest card. *ThE d ot StArThere are two Regular Expressi<strong>on</strong>sthat, when put together, mean “geteverything.” They are a dot followedby a star, like this:/folder<strong>on</strong>e/.*index\.phpIn this example, our RegularExpressi<strong>on</strong> will match to everythingthat starts with folder<strong>on</strong>e/ andends with index.php . This meansif you have pages in the /folder<strong>on</strong>edirectory that end with .html (I seethat a lot), they w<strong>on</strong>’t be a match tothe above RegEx.Now that you have an example, you might be interested in why thisworks. A dot, you may remember, means get any character. A starmeans repeat the last character zero or more times.This means that the dot could match any letter in the alphabet,any digit, any number <strong>on</strong> your keyboard. And the star right afterit matches the ability of the dot to match any single character, andkeep <strong>on</strong> going (because it is zero or MORE) – so it ends up matchingeverything.Hard to wrap your head around this <strong>on</strong>e? Trust me, it works.a D va N Ced tI pCustom Advanced filters in <strong>Google</strong> <strong>Analytics</strong> often require you to “getall” and make it a variable. For example, when you want to add thehostname to the Request URL (a very comm<strong>on</strong> filter), do it like this:Notice how we put parentheses around the .*, like this: (.*) – youcan see this in the boxes <strong>on</strong> the right side of the filter. To GA, in theadvanced filter secti<strong>on</strong>, this means get all, and put it in a variable. Sowe get the entire hostname (in a variable), the entire request URL ina variable, and then in the bottom field, we are able to specify get thefirst variable in Field A, and to it, add the first variable in Field B.18

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

Saved successfully!

Ooh no, something went wrong!