Reputation: 1896
We have two different Facebook accounts (ourselves and our clients) that both have conversion tracking requirements, though the requirements for both of the accounts are different.
I understand that I am able to set up multiple pixel ID's, if the events being sent are universal:
fbq('init', 'xxxxxxxxxxxxx1');
fbq('addPixelId', 'xxxxxxxxxxxxx2');
fbq('track', 'PageView');
However, I am wanting to send different events to different accounts. With the fbq push method, there seems to be no parameter to specify an account ID.
For example, we would want to track the add to cart button as an "add to cart" event, however our client wants to track them as a lead:
<script>
fbq('track', 'AddToCart');
</script>
<script>
fbq('track', 'Lead');
</script>
When executing the above example, both events are sent to both accounts. What I would like is something as below, where the account is explicit:
<script>
fbq('track', 'AddToCart', {'id':'xxxxxxxxxxxxx1'});
</script>
<script>
fbq('track', 'Lead', {'id':'xxxxxxxxxxxxx2'});
</script>
In the pixel itself there is an ID query parameter, though I have not found how to set this within the pushes. Is there any way to set pixel id in the pushes for the new Facebook events?
** Update **
We have tried running 'init' prior to every 'track' to overwrite the previous tracker, however this still sent all events to all facebook tags on the site.
Upvotes: 2
Views: 1008
Reputation: 23
To use init
was right idea but since now in a false way. Instead of trying to replace the previouse one, you should just add all your pixelIds by init
.
fbq('init', 'xxxxxxxxxxxxx1');
fbq('init', 'xxxxxxxxxxxxx2');
fbq('init', 'xxxxxxxxxxxxx3');
fbq('track', 'PageView');
Facebook is trying to deprecate the addPixelId
. I found that solution here
If you want to differenciate between them, try to clone the fbq object and use them instedt. But iam not sure if that really works due to the internals.
var pixelA = Object.assign({}, fbq),
pixelB = Object.assign({}, fbq),
pixelC = Object.assign({}, fbq);
pixelA('init', 'xxxxxxxxxxxxx1');
pixelB('init', 'xxxxxxxxxxxxx2');
pixelC('init', 'xxxxxxxxxxxxx3');
pixelA('track', 'PageView');
Upvotes: 1