No Enhanced Ecommerce?  No problem, with RegEx you can enhance your data view to solve limitations!

regex

“A sequence of characters that define a search pattern!”

So what are regular expressions, commonly know as regex, and what can they do for you?  Let’s start with a definition from good ole Wikipedia, the free encyclopedia…

regular expressionregex or regexp (sometimes called a rational expression) is, in theoretical computer science and formal language theory, a sequence of characters that define a search pattern.  Usually this pattern is then used by string searching algorithms for “find” or “find and replace” operations on strings.

This leads us perfectly into our Google Analytics topic here and why regex is an important resource for extracting data otherwise concealed.  Let’s say you have Ecommerce Tracking enabled on your site but you don’t have the Enhanced Ecommerce Tracking version configured.  This limits the accessibility of data and your ability to answer a wide range of critically important e-commerce questions; like “What’s going on in my Product Category (Enhanced Ecommerce)”? 

Have no fear, RegEx is here!  Really you’ll feel much better about it in the coming paragraphs.

If you haven’t heard about my “E-commerce Woes” before, you’re lucky – it’s getting a little long in the tooth.  So here I am crippled by the restrictions of antiquated e-commerce software and you guessed it, no Enhanced Ecommerce tracking, so what’s a fella to do?

Here’s the question…

Sales; David which of our product categories are producing the largest order volume for organic traffic? 

David; Um, I’don’t know we don’t have Enhanced Ecommerce tracking configured!

Sales; Really? 

David; Yeah, really!

Below is an example of the sort of URL (Uniform Resource Locator) I’m dealing with…

Category Specific:  https://spectrum-nasco.ca/catalogpc.htm?Category=EM%20-%203-D%20GEOMETRY

Using regular expressions we can identify the URLs URI path & query components in a Custom Segment within Google Analytics.

URI:  /catalogpc.htm?Category=EM%20-%203-D%20GEOMETRY

RegEx:  ^\/[a-z]{9}\.[a-z]{3}\?[a-z]{8}\=EM[s\a-z0-9\s\%\$\#\@\!\-\_\:\;\,\.\?]*$

GA Custom Segment Advanced Conditions

Create an Advanced Condition and include regular expression(s) to match the page URI components (path, query and fragment) by session or user.

With example in hand it doesn’t take too much effort to begin dissecting what’s going on here; however experience and knowledge are key to defining your own set of Regular Expressions for your unique requirements.

If you want to learn more about Regular Expressions check out Regular-Expressions.info and Analytics Help About regular expressions (regex) and if you want to test your Regular Expressions check out regular expressions 101 or RegExr.

To expand on this segments condition you could add Enhanced Ecommerce; select “Purchased an item” tab and under “Revenue” select the “per user” tab and select the greater than symbol tab “>” and enter “1” in the input field.  This will filter any users that have made a purchase as attributed to the category identified by your Advanced Conditions regular expressions, see below.

GA Custom Segment Enhanced Ecommerce

Add Enhanced Ecommerce per user or session to Conditions and reveal revenue attribution across your Custom Segments.

As an aside, there are all kinds of places your new found regex knowledge will come in handy when using Advanced Filters for things like Goals or when using the Primary Dimension Advanced Search for Include and Exclude Filters.

Now we don’t have to cringe when asked those dreaded sales questions like the one above, really!  

David; Yeah, really!


David Moores

Advanced knowledge of web server deployment, database management systems, and server-side scripting languages. Strengths lie in digital analytics, metric components and the implementation of data tracking methods for mining interpretation. The body of my work has been a balance of problem solving and technical know-how. I love a problem and love solving them even more!

Leave a Reply