Managing two facebook pixels on the same page

1.6k Views Asked by At

I am working on a large companies website where several different agencies help with media campaigns. We currently have more than one facebook pixel on some pages of the site. They are effectively working, but I can't keep both from firing all events being tracked on the page.

for example:

window.fbq("init", "111......1");
if(conditionA){
  //I would like this to be only for pixel 111.....1
  fbq("track", "PageView");
}

if(conditionB){
  window.fbq("init", "222......2");
     //I would like this to be only for pixel 222.....2
  fbq("track", "ViewConent");
}

jQuery(document).on("click", "#buttonA", function(){
    //I would like this to be only for pixel 111.....1
    window.fbq(track", "Lead");
}

Is there a way to control what track event gets fired for a specific ID? In this example right now the 111 ID is getting all three events. The 222 ID is getting the "PageView" event if both conditionA and conditionB are true. The 222 ID is getting the "Lead" event if conditionB is true.

I understand why this is happening, but is there a way to specify what ID I want to be used for an event?

1

There are 1 best solutions below

0
On

I just found the answer. There is a "trackSingle" https://developers.facebook.com/docs/facebook-pixel/events-advanced-use-cases/v2.11

example:

window.fbq("trackSingle", "111........1", "Lead");