When trying to report on traffic from coming Facebook to your site, you can come across multiple instances of Facebook across several Source/Medium rows.
Most commonly, you can expect to see facebook.com, m.facebook.com, l.facebook.com and lm.facebook.com.
This can be quite a pain in the neck when configuring your reports for Facebook traffic.
Why does this happen?
Facebook sends traffic through two main domains based on the device the user is on – Desktop or Mobile. This is indicated by the letter M in the subdomain, i.e. m.facebook.com and lm.facebook.com.
On top of that, Facebook uses a mechanism called Link Shim that sends the user via a redirect before landing on your site. This adds the letter L to the subdomain, i.e. l.facebook.com and lm.facebook.com.
This mechanism serves two purposes:
- Protecting the user’s privacy – if the user clicked a link on their Facebook profile, the referral URL (Full Referrer) would show their profile link, which is personally identifiable information (PII)
- Protecting the user from malicious links – Before sending the user to the external link, Facebook checks that the link is legit against a list of malicious sites built by Facebook, Google McAfee and others.
How to solve this
Solving this is pretty easy, by adding a simple ‘Search and Replace’ filter on your Google Analytics view.
- Open Google Analytics and navigate to the admin section
- Under the relevant view, click Filters and then ‘Add Filter’
- Select ‘Create new Filter’
- Name the filter something descriptive, e.g. ‘Facebook referrer rewrite’
- Set the Filter Type to Custom
- Select Search and Replace
- Set the Filter Field to ‘Campaign Source’
- Under ‘Search string’ paste ^.*.facebook.com
- Under ‘Replace string’ paste facebook.com
- Save the filter
Pro tip:
Always create a backup view for your property that doesn’t have any filters applied to it
You can also verify your filter before saving to examine how the filter would have impacted your past seven days data. The table below shows the values impacted and the expected output of the filter.
The bigger issue with Facebook tracking in Google Analytics
The key issue with Facebook tracking in Google Analytics is the inability to distinguish between Paid and Organic traffic coming from Facebook. Google can’t tell apart these traffic types, so if you’re reporting on Paid Facebook campaigns using Google Analytics you could run into attribution issue.
The standard mechanism for solving this is by using UTMs in your Facebook ads, so that a user sent to your site from a campaign will be clearly marked for Google Analytics.
For example, a user will be sent to the link:
https://www.example.com/product?utm_source=facebook&utm_medium=ppc&utm_campaign=summer-2020
These UTMs can be added in Facebook in one of two ways:
- Directly on the Website URL you’re sending the users to. You can use Facebook’s built in tool for that
- You can also use the URL Parameters box to add these. Using this box makes the UTM management easier across the entire account.
Using Facebook’s native UTM tool can also inject dynamic parameters from Facebook, e.g. the Campaign’s ID or the Ad Set’s name for more granular control at scale (although some might argue that these are notoriously error prone).
5 Responses
היי,
במאמר המצויין שלך על סינון תוצאות פייסבוק באנליטיקס, לא ברור באיזה מחרוזת חיפוש להשתמש. בטקסט ההסבר היא מופיעה בצורה אחת, ובתמונה בצורה אחרת
https://prnt.sc/uvgz54
https://trackingchef.com/google-analytics/fixing-facebook-referrer-tracking-in-google-analytics/
אשמח אם תוכל להבהיר,
תודה, רונן
האמת ששתי האפשרויות פועלות באותה המידה, אבל איחדתי כדי שיהיה עקבי יותר
תודה שהסבת את תשומת ליבי 🙂
בכייף! רק שים לב שעדיין יש סלאשים (\) בסטרינג השני ובראשון לא [אני יודע ששניהם עובדים אבל זה עדיין עשוי לבלבל
תודה שוב, אלוף!
https://prnt.sc/uvjq54
I was having difficulty verifying the filter you’ve provided and then I noticed that the RegEx in step 8 of your post (^.*.facebook.com) is actually different than the RegEx in your screenshot (^.*\.facebook\.com) so I tried that. Unfortunately, that didn’t work either so I came up with my own and wanted to share with you. This is the RegEx that allowed to me verify the filter was working correctly: ^*\.facebook\.com$
Hey Adam, thanks for sharing your variation 🙂
All three work, though there is slight some nuance between them.
Note the Regex string you’ve written has a multiplier (*) without any preceding character.
Mine arguably use a dot w/o a slash (i.e. escaped) which potentially could return any character too.