Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Will it cause any issue if I use multiple Facebook Pixel in one page?

Tags:

facebook

I would like to include both my Facebook Pixel id and customer's Facebook Pixel id in one page, so both of us can have some insight about users, and customer can also create ADs for the page if he or she wants to.

I already test tracking and it seems to work fine. However I do receive warnings from Pixel SDK about "Multiple different pixels were detected on this page".

Since I cannot find any information about this scenario, I would like to know whether it is okay to do so ?

Thanks

like image 843
Rangi Lin Avatar asked Jan 07 '16 07:01

Rangi Lin


People also ask

Can you put two Facebook pixels on one page?

Yes, you can have multiple Facebook pixels on a website. Generally you will only have one Facebook pixel on a website, but it is possible to install multiple Facebook pixels on site if needed.

Should you use multiple Facebook pixels?

The only time you really need multiple Facebook Pixels is if you have websites with very different audiences. For example if you have a website for your business and then you also have a website around some unrelated hobby like knitting – or standup comedy (which is on my own website, I know).

How many Facebook pixels can I have?

You can create up to 100 pixels in your Meta Business Manager account. If you reach the limit of 100 Meta Pixels, but you need to create another Pixel, you can create a new ad account, which will let you create 1 new Pixel. You can then assign permission to the new ad account and new Pixel to your Business Manager.

Should I use a different Facebook pixel for each website?

The short answer is: yes! Some people think that you need to create a new pixel for every website but that actually can remove some of the power you have with the Facebook pixel. You can have multiple Facebook Pixels but you often don't need them. The pixel will “learn” more effectively with more traffic.


2 Answers

I had the same requirement and I found that it is possible and you don't need to hack the Facebook pixel code.

Even if it is not documented, the fbq object support multiple pixel ids.

Just call multiple times the init function with different pixel ids. Then, then when you do fbq('track', "PageView"); it will issue one event per pixel. You can call fbq('track', '{{your_event_name}}')as many times as you want and it will track the event for all previously initialized pixels.

So your final code would look like this:

<script>     !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','//connect.facebook.net/en_US/fbevents.js');     fbq('init', '{{pixel_id_1}}');     fbq('init', '{{pixel_id_2}}');     fbq('track', "PageView"); </script> <noscript>   <img height="1" width="1" style="display:none" src="https://www.facebook.com/tr?id={{pixel_id_1}}&ev=PageView&noscript=1" />   <img height="1" width="1" style="display:none" src="https://www.facebook.com/tr?id={{pixel_id_2}}&ev=PageView&noscript=1" /> </noscript> 

Edited April 2019 @chuck-le-butt found that a blog post from facebook document how to use the pixel: https://developers.facebook.com/ads/blog/post/2017/11/28/event-tracking-with-multiple-pixels-tracksingle/

like image 124
Julien Bachmann Avatar answered Oct 06 '22 20:10

Julien Bachmann


FWIW, Facebook has added trackSingle and trackSingleCustom events (as of November 2017) to allow selectively firing events on specific pixels when multiple pixels are initialized on a page.

Docs: https://developers.facebook.com/docs/facebook-pixel/events-advanced-use-cases/v2.12#multipixels.

Blog Post: https://developers.facebook.com/ads/blog/post/2017/11/28/event-tracking-with-multiple-pixels-tracksingle/

like image 43
t-storm Avatar answered Oct 06 '22 20:10

t-storm