Clever SEO Keyword Grouping with Regex in Google Analytics
Although Google Analytics offers many different report types and quite a lot of options to filter and refine them: One thing is not really doable without Regular Expressions: Checking the traffic for keyword groups!
Imagine the following example: You want to check the visits for a set of specific keywords. Let´s say call this group “christmas keywords” and it should match all this keywords: christmas, xmas, x-mas, santa claus, advent, chrimbo, yule, gift idea etc…
Just the right keyword group to measure the outcome of your Seo optimization for christmas!
You could get the idea and create an Advanced Segment with 8+ “Keyword contains” Rules. That works but it is a bit painful to do so many rules in one Segment (…and Google Analytics users are like all other users very lazy ). Moreover, you can´t put more than 20 rules like this. So what if you want to check bigger keyword groups? Let me show you which cool things you can do with bigger keyword groups with 3 simple examples:
The Basic SEO Keywords Group Regex
The easier and more powerful solution is to use an Advanced Segment with “Keywords matches Regular Expression” rule:
christmas|xmas|x-mas|santa claus|advent|chrimbo|yule|gift idea|and so on…
This simple, but powerful regular expression uses the “|” Alternation operator. So “christmas|xmas” basically means “match ‘christmas’ OR ‘xmas’“. Easy isn´t it? In Google Analytics this will just anything that contains any of the mentioned words.
The Regex for Keywords Groups Excluding Combined Keywords
You could might want to make your keyword group more specific and exclude combined words like “christmastree” or “christmaspresent” and you only want to match keywords that contain “christmas” without the combined words like “christmasparty“. You can use the regex:
The “\b” is the word boundary. It just marks the End/Start of a word. So this won´t match “christmastree” or “xmastree” anymore, since the second \b requires that after christmas needs to be the end of the word. It will match “christmas tree” though. Important: Note the use of the round brackets here! “\bchrismas|xmas\b” would match words that begin with “christmas” or end with “xmas“! It´s like in mathematics: 5 * 1 + 3 is not the same like 5 * (1 + 3)
The regex for exact match keywords
Too make it even more specific: It might be useful for you too have a keyword group that matches only EXACTLY the keywords that you want, and nothing else. Check the following example: (let´s use some other example keywords, I have already enough of “xmas” )
^(keyword|keywordlist|keywordresearch|seokeywords|seo-consulting|seotips|search engine optimization)$
The carret “^” marks the begin of the line, while the “$” marks the end.
This really only matches the keywords “keyword”, “keywordlist“, “keywordresearch“,”seokeywords“, “seo-consulting“, “seotips“, “search engine optimization“. It won´t match for example: “keyword analysis” or “seo guides” – It wont even match “seo consulting” or “searchengine optimization“, it really just matches the exact keywords that you choose for your Segment and a “-” instead of ” ” is already too much of a difference. Note again the use of the round brackets!
Just a note: In Google Analytics you can use Regex also at the bottom of the reports:
Another Note: There is a max. length of the regular expression that you can use in Google Analytics! After trying extremely long regex (Yes, I needed to try it out )Google Analytics refused to accept them and popped out errors.
And yet another Note: There are actually more interesting ideas to use Regular Expressions in analytics: Cool is to check for number of keywords in the query-keywords. This is nice to analyze how “longtailish” your SEO traffic is.
For the case that you want to learn more about Regex: A very good regular expressions tutorial you can find at www.regular-expressions.info – There all Regex are explained in detail and there you can find good how-to examples and examples of the most common pitfalls of regex.
The more visits your website has the more fun it is to do keyword grouping I hope that was a helpful tip for you. Any doubts? => Comment.