Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to block Facebook pixel? #67

Open
tdrzewosz opened this issue Jul 8, 2021 · 2 comments
Open

How to block Facebook pixel? #67

tdrzewosz opened this issue Jul 8, 2021 · 2 comments

Comments

@tdrzewosz
Copy link

tdrzewosz commented Jul 8, 2021

How to block Facebook pixel?

This code is not working.

analytics_ext: { // Existing category Unique name // This example shows how to block Google Analytics category: 'tracking', // Type of blocking to apply here. // This depends on the type of script we are trying to block // Can be: dynamic-script, script-tag, wrapped, localcookie type: 'dynamic-script', // Only needed if "type: dynamic-script" // The filter will look for this keyword in inserted scipt tags // and block if match found search: 'analytics', // List of known cookie names or Regular expressions matching // cookie names placed by this service. // These willbe removed from current domain and .domain. cookies: [ { // Known cookie name. name: '_fbp', // Expected cookie domain. domain:.${window.location.hostname} } ], language: { locale: { de: { name: 'Facebook Pixel' } } }

thanks

@tdrzewosz
Copy link
Author

It doesn't working. I see the _fbp cookie

@Streamlinelv
Copy link

Streamlinelv commented Nov 3, 2023

Hey @tdrzewosz
Have spent a bit of time trying to figure this one out myself and got it working using "script-tag".
Here is my HTML:

<!-- Facebook Pixel Code -->
<script type='text/plain' data-consent='facebook'>
	!function(f,b,e,v,n,t,s){if(f.fbq)return;n=f.fbq=function(){n.callMethod?
	n.callMethod.apply(n,arguments):n.queue.push(arguments)};if(!f._fbq)f._fbq=n;
	n.push=n;n.loaded=!0;n.version='2.0';n.queue=[];t=b.createElement(e);t.async=!0;
	t.src=v;s=b.getElementsByTagName(e)[0];s.parentNode.insertBefore(t,s)}(window,
	document,'script','https://connect.facebook.net/en_US/fbevents.js');

	fbq('init', 'XXXXXXXXXXXX');
	fbq('track', "PageView");
</script>
<noscript>
	<img height="1" width="1" alt="Facebook tracking" style="display:none" src="https://www.facebook.com/tr?id=XXXXXXXXXXXX&ev=PageView&noscript=1" />
</noscript>
<!-- End Facebook Pixel Code -->

Note above how I have added type='text/plain' and data-consent='facebook' inside <script> tag.
Now you can exclude Facebook pixel like so:

facebook_script_tag: {
	category: 'statistics',
	type: 'script-tag',
	search: 'facebook',
	language: {
		locale: {
			en: {
				name: 'Facebook'
			}
		}
	}
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants
@Streamlinelv @tdrzewosz and others