Technology Services

Segmenting Social Media Traffic Using Regular Expressions

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.

Author

jlo

Share
Published by
jlo

Recent Posts

Building a Scalable Analytics Program: When to Bring in DXA Tools like Contentsquare

Most analytics programs begin with foundational platforms like Google Analytics or Adobe Analytics. These tools…

2 weeks ago

Mastering GA Custom Metrics – Best Practices & Pitfalls to Avoid

In our previous post, we covered why custom metrics in GA matter and how to…

3 weeks ago

Unlocking User Behavior: The Power of Session Replay + AI Analytics

In today’s fast-paced digital world, marketing and product teams don’t just need data—they need answers,…

3 weeks ago

This website uses cookies.