Facebook referrals in Google Analytics are a topic that, at least in my case, causes frustration with the chaos that outbound Facebook links bring into the orderly, analytical world of Google Analytics. The solution may be to group channels or use an advanced filter to assign traffic to a specific location.

As far as you know how to do this, that would essentially be all in the subject of the entire post. However, if you want to understand where it actually comes from and why Facebook does it, you are in the right place and I strongly encourage you to read it all. I hope that my post will contribute to the “aha” moments (ie: aha, that is actually logical). So get to work!

Where can we find Facebook referrals in Google Analytics?

References from Facebook (or “referrals”) are available in the Acquisition -> Medium Sources tab with the addition of the Source / Medium dimension includes “Facebook”. If we conduct organic and paid activities, we should see both referral and paid / social media in the medium. 

Our links in the basic version may look similar to those presented in the screenshot below (from the statistics of my website). The markings before Facebook can be a bit confusing, so what do they mean?

Facebook referral
Source: https://unsplash.com/photos/CTZhGbSxWLI

Privacy encrypted in a link

The topic seemed so interesting to me and at the same time aroused my curiosity that I decided to look for the sources of these changes in the referrals from Facebook. It turns out that, to protect privacy, the tool through which the link passes is tagged to mark it as safe. This tool is Facebook’s internal tool called Link Shim.

As the developers and creators of this system admit, it was created in 2008 to protect users against spam or malicious content. A “link support” works every time a link is clicked, and its content is checked and marked as safe (or unsafe). The malicious URL is detected at this stage and the user receives information that the website is not secure.

Why is a system needed here? On social networks, we operate under our real name and surname (as a rule) and each referral would contain our exact personal data and would reveal too much about us and at the same time unlawfully protect our data.

Facebook referrals markings

The letters placed by the name of the source indicate the device from which the given user comes. The second thing that is visible in a given link is whether it has passed through the Link Sim system.

  • l.facebook.com – desktop, went through Link Shim
  • lm.facebook.com – mobile, went through Link Shim
  • m.facebook.com – mobile

Data filtering

You can easily organize all your Facebook referrals in one place. Just create a filter in Google Analitycs with the command “search and replace”.

Find string: .*\.facebook\.com$

Replace string: facebook.com

Watch Love Data explanation


Facebook referrals require in-depth analysis and grouping them in a logical way so that they are more readable in our reports. An option worth considering is the filter method presented in this entry, but the second option is also channel grouping.

It is always worth bearing in mind that the use of filters requires consideration of their operation, because they permanently and irremovably remove the data that we collect in Google Analytics. They also don’t work retroactively, and the order in which the filters are set determines the order in which they operate.

I hope that the information presented is interesting and valuable also for you. Share your best methods for referrals in a comment! Read more about Facebook tips!