or   Register or Register today to make and share your own cheat sheets! (Why Join?)

Cheatography Login

Join Us!

Not a Cheatographer? Register here!

Social Media

You can login to or register with Cheatography using your Facebook or Twitter account!

Why Join Cheatography?

Make and share cheat sheets!
Join a great community of Cheatographers and add your very own contributions.

Save your favourites!
Quick access to your most loved cheat sheets.

Fewer ads!
Members see no ads on the site.

Coming soon ...
Requests, ratings and more!

Why Join Cheatography?

Make and share cheat sheets!
Join a great community of Cheatographers and add your very own contributions.

Save your favourites!
Quick access to your most loved cheat sheets.

Fewer ads!
Members see no ads on the site.

Coming soon ...
Requests, ratings and more!

Google Analytics Regular Expressions Cheat Sheet by Jay Taylor

11 Comments   |   Add a Comment   |   PDF Download   |   Find:

Anchors

^ Start of line
$ End of line

Character Classes

\s White space character
\S Non-white space character
\d Digit character
\D Non-digit character
\w Word
\W Non-word (e.g. punctu­ation, spaces)

Metacharacters (must be escaped)

^ [ ]
$ ( )
. { }
* + ?
\ | -

GA Filter group accessors

$Ax Access group x in field A (e.g. $A1)
$Bx Access group x in field B (e.g. $B1)
 

Quantifiers

* Zero or more (greedy)
*? Zero or more (lazy)
+ One or more (greedy)
+? One or more (lazy)
? Zero or one (greedy)
?? Zero or one (lazy)
{X} Exactly X (e.g. 3)
{X,} X or more, (e.g. 3)
{X, Y} Between X and Y (e.g. 3 and 5) (lazy)

Ranges and Groups

. Any character
(a|b) a or b (case sensitive)
(...) Group, e.g. (keyword)
(?:...) Passive group, e.g. (?:key­word)
[abc] Range (a or b or c)
[^abc] Negative range (not a or b or c)
[A-Z] Uppercase letter between A and Z
[a-z] Lowercase letter between a and z
[0-7] Digit between 0 and 7
 

Sample Patterns

^/di­rec­tor­y/(.*)
Any page URLs starting with /direc­tory/

(bra­nd\­s*?­term)
Brand term with or without whitespace between words

^br­and­\s+­[^cf]
Key phrases beginning with 'brand' and the second word not starting with c or f

\.as­px$
URLs ending in '.aspx'

ORDE­R\-­\d{6}
"OR­DER­-" followed by a six digit ID

(?:\­?|&)u­tm=­([^­&$­]+)
Value of 'utm' querys­tring parameter

Favourited by 11 Members:

Tim Leighton-Boyce tonicarr kagua maintainweb fire9 schrodervictor The_Frail Matmal parastudio cthumerelle Dranzz

Comments

DaveChild DaveChild, 08:11 11 Feb 12

Great cheat sheet, Jay, especially the sample patterns!

Jay Taylor Jay Taylor, 18:10 11 Feb 12

Thanks Dave! Obviously it's based heavily on your main RE one, I'm really hoping Google will add support for assertions in the future, would make life so much easier!

Brian CLifton Brian CLifton, 09:59 23 Feb 12

Nice cheat sheet Jay

I don't think you need this one:
(bra­nd\­s*?­term)

as just (brand) will work, no? That is, (brand) will match:
"brandterm", and "brand term"

Sean Hughes Sean Hughes, 09:59 23 Feb 12

Excellent cheat sheet Jay, really helpful.

Tim Leighton-Boyce Tim Leighton-Boyce, 10:07 23 Feb 12

This is really helpful. Thank you Jay. Just the kind of resource we need.

Modi Modi, 15:19 26 Feb 12

Good stuff Jay! Thanks for sharing.

Marc Beharry Marc Beharry, 14:44 6 Aug 12

thanks much Jay!!

Chaitanya Chaitanya, 14:44 6 Aug 12

Great information, really awesome..

Surbhi Surbhi, 13:16 6 Mar 13

Cant thank you enough for this amazing resource!

gabe gabe, 17:16 26 Mar 13

I do have a file name LIKE maxfile_[A-Z]_[0-9]{6} and I want to use a wild card like ^maxfile_ but it does not work

James James, 16:30 5 Apr 13

Hi guys,

Just a short question on using the right regular expression. I want to create a funnel which has to gather information on different URL's. The one thing that all the URLs have in common is their last part. For example, i want to include al these URL's in one step of a funnel:

book/cabin/step4
orange/keyboard/stairs/step4
ball/step4

> They all have the same last part; 'step4'. Which regulare expression do i have to use to collect the data of all these different pages?

Hope you can help me!
James

Add a Comment

Comment:

Contents

A list of Regular Expression functi­onality supported by Google Analytics

Column Content Comments Author Updated
- Google Analytics Regular Expressions Cheat Sheet Jay Taylor 13 Feb 12
1 Anchors 0 Jay Taylor 10 Feb 12
Character Classes 0 Jay Taylor 10 Feb 12
Metacharacters (must be escaped) 0 Jay Taylor 13 Feb 12
GA Filter group accessors 0 Jay Taylor 10 Feb 12
2 Quantifiers 0 Jay Taylor 10 Feb 12
Ranges and Groups 0 Jay Taylor 13 Feb 12
3 Sample Patterns 0 Jay Taylor 10 Feb 12