Google Analytics: Using Regular Expressions to Jump Onto More Data!

Julie Waite

This post is the second in a series on Google Analytics by Chris Casarez, a Google Analytics consultant and employee of Transamerican Auto Parts, a Bronto client (read 1st post)

In the first post in this series on email marketing and Google Analytics (GA), we discussed the importance of tracking email campaigns. Specifically, we detailed the components of the GA URL builder.

This week we’ll tackle how to use regular expressions in GA to dive deeper in segregating data and pulling more meaningful reports. The more consistently and logically you name your email marketing campaigns in GA, the more you will be able to do so using regular expressions (and other advanced features).

Regular Expressions

Regular expressions (regex for short) consist of a series of characters that allow you to combine or filter information in a manner that would not be possible otherwise. Because GA accepts regex syntax, you can use it to combine values (ie. keywords, campaigns, site searches, referral sources, landing pages, etc.) and pull comprehensive reports that would not be possible otherwise. Pipes (|) and dollar signs ($) are the two of the most useful characters you can use.

| (Pipes)

*Allows you to separate multiple values *Enables you to search for multiple values (like keywords)

For example, if you need to know the revenue earned from 2 specific email campaigns, use regex to pull information for both of these campaigns using pipes to separate the campaign names. In order to see campaign-level data, click “Traffic Sources” on the left nav, then “Campaign.”

In this example, email campaigns have been named according to the dates they were sent.

Ex. 1: Google Analytics – All Campaigns

So let’s say you want combined metrics for emails that were sent on 4/3/09 and 4/17/09. Use pipes to separate the names of the target campaigns, and enter these values into the campaign filter at the bottom of the campaign report. In this scenario, you would enter: 04-03-09|04-17-09

Ex. 2: Google Analytic Campaigns – Regex Pipes

The resulting report shows all email campaigns sent on 4/3/09 and 4/17/09. But what if you don’t want region-specific reports because they don’t contain the data you are measuring? (for example, 04-17-09_cpt was an email sent to recipients near Compton, CA to announce a local event). Fortunately, regular expressions also allow you to filter characters out.

$ (Dollar Signs)

*Allows you to ensure a value ends with a specific character*Enables you to filter out similarly named unwanted values

Using the $ character, you can ensure your results filter out subsequent characters. So while filtering for 04-03-09 will include the 04-03-09_WA campaign, filtering for 04-03-09$ will ensure that only 04-03-09 is filtered for (the dollar sign ensures that the character to its left is the last character in the sequence). So by combining the $ and | characters, we can filter for the specific campaigns. In this scenario, you would enter: 04-03-09$|04-17-09$

Ex. 3: Google Analytics – Regex Pipes & Dollar Signs Combined

Other uses for Regular Expressions

In addition to filtering for campaign data, you can also use regex syntax to filter information for other GA metrics. Regex can also be cross-referenced with other advanced GA features, like automated email reporting or advanced segments. The more you experiment with regex syntax, the more meaningful data you will be able to gather. Regex is easy to learn and in the long run, can save you a lot of time and frustration when pulling comprehensive reports.

Chris Casarez is a Google Analytics consultant and employee of Transamerican Auto Parts, a Bronto client. You can read constantly updated Google Analytics tutorials on his website: www.seoracle.com and received updates via his twitter account.