I’ve been working on a project for a client and one thing they wanted to know was “what percentage of my overall traffic is from social media?”. This lead into a deep discussion of Reach on the channels they were engaging, and got me looking at creating some Advanced Segments to isolate traffic down to only refers from particular social media sites.

Depending on which type of analytics tool you use, your regular expression might differ, but because I spend 95% of my time in Google Analytics, I’m dedicated this post to it.

Like many things in life, there is more than one option for creating the same segment. John Doherty from Distilled wrote a great port on segmenting social traffic in Google Analytics one way, but I’m here to show you another way using regular expressions (also referred to as REGEX). I would recommend reading a beginner’s guide on regular expressions. Or, you may wish to download and print off a copy of the REGEX cheat sheet for your reference in case you plan to write your own advanced segment later on.

To include .com, or not to include .com? That is the question!

Without .com = facebook|twitter
With .com = facebook.com|twitter.com

Difference = 276

Do you see why? Ahh, people are using it in their URL!

Although the above value is not large in this sample, the number can slowly creep up to you if you are segmenting more channels that others have used in their URL, whether it be a sub-domain or within the domain itself.

**TIP: If you’re working on with a huge chunk of data and you run this Advanced Segment, you most likely will run it via “fast access mode”. To avoid this, you can go into your Traffic Sources report, paste your REGEX into your inline filter at the bottom (top for V5), and voila! You’ve escaped the fast access creeper (note: the inline filter for V5 is not set to REGEX initially and you would need to click on the Advanced link next to the text box to select it).

I hope this helps clean the data up a bit! Let me know if you would write the regular expressions differently, I’d be curious to know.