About cookies on this site

We use cookies to collect and analyse information on site performance and usage, to provide social media features and to enhance and customise content and advertisements. Learn more

Cookie settings

About cookies on this site

Cookies used on the site are categorized and below you can read about each category and allow or deny some or all of them. Learn more

Necessary

Some cookies are required to provide core functionality. The website won't function properly without these cookies and they are enabled by default and cannot be disabled.

Preferences

Preference cookies enables the web site to remember information to customize how the web site looks or behaves for each user. This may include storing selected currency, region, language or color theme.

Analytical cookies

Analytical cookies help us improve our website by collecting and reporting information on its usage.

Marketing cookies

Marketing cookies are used to track visitors across websites to allow publishers to display relevant and engaging advertisements. By enabling marketing cookies, you grant permission for personalized advertising across various platforms.

  • Courses
    • Paid courses
    • Course bundles
    • Free courses
  • Blog
  • Resources
    • Youtube channel
    • E-books and Guides
    • GTM Recipes
    • View All Resources
    • GTM Community
    • GA4 community
  • Services
  • About
    • About
    • Contact
  • Login
  • Courses
    • Paid courses
    • Course bundles
    • Free courses
  • Blog
  • Resources
    • Youtube channel
    • E-books and Guides
    • GTM Recipes
    • View All Resources
    • GTM Community
    • GA4 community
  • Services
  • About
    • About
    • Contact
  • Login

August 23, 2022

How to Remove FBCLID from Google Analytics 4?

When I am writing this blog post, Google Analytics 4 does not have a native method to easily remove unwanted URL query parameters. As a result, your reports might look something like this:

See all those fbclid=xxxx? They make your reports harder to read, and if the same page was visited by multiple users from Facebook, that page would be displayed as different/unique pages.

That is why excluding query parameters is useful.

In this blog post, I will explain how to remove fbclid from Google Analytics 4 reports and make your data cleaner.

Sure, you could use a dimension called Page path (that does not contain query parameters), but maybe I want to analyze data including *some* query parameters. I just don’t want to see those parameters that pollute my reports, including fbclid.

 

What is FBCLID?

Every time a visitor clicks any link on Facebook that redirects him/her to your website, Facebook adds an additional parameter to the URL, called fbclid. FB uses that to keep tracking you as you navigate across websites.

Despite the privacy issues, another drawback of this method is that your analytics reports get polluted because every link for every visitor will have a unique fbclid value. This means, that the same page/URL in your reports will be reported as multiple unique pages.

 

Custom template

Since GA4 at the moment (when I am writing this blog post) does not have the built-in feature, we are going to use Google Tag Manager to exclude URL query parameters. This means that your GA4 also must be installed with GTM.

Login to your Google Tag Manager web container’s interface and go to Templates.

Then click Search Gallery in the Variable templates section.

Find the template that is called Trim Query. It was created by Ayudante, a Tokyo-based consulting and mobile software development company. Big thanks to them!

Click Add to workspace and then Add.

 

Create a variable that excludes query parameters

By using the aforementioned custom template, let’s create a variable. Go to Variables > New > Variable configuration and select “Trim Query” as a variable type.

Select Page URL as a Target URL (because this variable will take the Page URL and will remove certain parameters). Keep all other settings as they are.

Note: this variable does not actually affect the page URL that your visitors see in the browser address bar. It will just return a cleaner URL as a value, and we will use it in GA4 tag(s).

Now we need to include fbclid in that list. In the screenshot below, I have added more than one but in the context of this article, the fbclid is a must. One row = one parameter that should be excluded.

Save the variable. I usually name it Page URL excluding unwanted query parameters.

Subscribe and Get the Ebook - working with reports in ga4

Update the GA4 configuration tag

When Google Analytics 4 is implemented, it automatically tracks things like page_location. But you can overwrite that. In the GA4 configuration tag that you should already have (if not, read this guide), add a new parameter page_location and set the aforementioned custom variable as its value.

Save the tag.

Is GA4 installed on a single-page application? Then I would suggest setting the same page_location parameter in all GA4 event tags as well.

Save your changes.

 

Test the setup

It’s time to test if everything is working properly. Click the Preview button at the top right corner of the GTM interface (to enable the Preview mode).

Then enter the URL of your website and also include several query parameters that you have excluded. You can also include some parameter that should still be displayed in the reports. All query parameters should be connected with &. Example: yoursite.com?fbclid=12345&xyz=888. Click Connect.

Once your GA4 tags have fired, go to Google Analytics > Configure > Debugview. Find your device, check the most recent events, and check if their page_location value does not contain the excluded parameters.

If everything is working fine, publish your GTM container by clicking the SUBMIT button and then completing all the other necessary steps.

 

What if you use GTAG?

Then take a look at this documentation. Your developer will need to write some custom code that sends the page_location parameter in the gtag code (without unwanted URL parameters). And your role here could be to prepare a list of unwanted parameters that should be later excluded by a developer.

Also, tell the developer that in the future, that list might be updated, and he/she will need to include those updates in the code.

 

Remove FBCLID from Google Analytics 4: Final Words

Will Google Analytics 4 offer a built-in feature to exclude query parameters? I hope so. Maybe when you are reading this guide, that feature is already available (in that case, please let me know in the comments. Maybe I just forgot to update this article 🙂 ).

But the lack of a built-in feature does not mean we cannot solve it ourselves. With this workaround, you can still have cleaner URLs in GA4 reports.

Keep in mind that this implementation will apply only to future data. Your historical data will still contain those unwanted URL query parameters.

Also, one more thing for those who use Google Analytics 4 to send the data to their server-side endpoint and then send it to Facebook Conversions API. If you are doing this, then the method I have explained should NOT be used; otherwise, fbclid will not be sent to FB.

Julius Fedorovicius
In Google Analytics Tips
3 COMMENTS
eduardo cabrera
  • Aug 29 2022
  • Reply

Hello,

Question:

By doing this "trim" will I affect the fbclid (and now the twclid) variables I have? Both required by Facebook and Twitter Pixels parameters?

    Julius Fedorovicius
    • Aug 29 2022
    • Reply

    It affects just GA4

eduardo cabrera
  • Aug 29 2022
  • Reply

Hello,

Quick question, by "trimming" the url will I affect the fbclid or twclid (new for Twitter) variables? Both required by the pixels parameters?

Leave a comment Cancel reply

Your email address will not be published. Required fields are marked *


 

Hi, I'm Julius Fedorovicius and I'm here to help you learn Google Tag Manager and Google Analytics. Join thousands of other digital marketers and digital analysts in this exciting journey. Read more
Analytics Mania
  • Google Tag Manager Courses
  • Google Tag Manager Recipes
  • Google Tag Manager Resources
  • Google Tag Manager Community
  • Login to courses
Follow Analytics Mania
  • Subscribe to newsletter
Recent Posts
  • Google Tag Manager event tracking – The Guide
  • Microsoft Consent Mode. How to Configure it?
  • DebugView in Google Analytics 4 not working? Here are 18 solutions.
Analytics Mania - Google Tag Manager and Google Analytics Blog | Privacy Policy
Manage Cookie Settings