如何在一个网页上放置多个Facebook跟踪像素? [英] How would I put multiple Facebook tracking pixels on one web page?

查看:295
本文介绍了如何在一个网页上放置多个Facebook跟踪像素?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在尝试使用Facebook的广告跟踪像素跟踪广告。
我们看了Facebook的文档,导致我没有在哪里。

We are trying to use Facebook's Ad tracking pixels to track ads. we looked at Facebook's documentation and that led me no where.

我需要知道如何在一个页面上触发多个Facebook像素,因为我们有多个广告投放

I need to know how to trigger multiple Facebook pixels on one page because we have multiple ads running.

我将代码放在每个像素上,并将其放在页面上,然后我们有一个Cart页面,我在其中启动或添加购买事件。但是由于我有脚本3次,似乎是3次。我想要每个像素点火一次。

I took the code that it gave me per pixel and placed it on the page and then we have a Cart page in which I fire or add the 'Purchase' event. But since I have the script 3 times it seems to fire 3 times. I want it to fire once per pixel.

这是我迄今为止所做的:

This is what I have so far:

<!-- Facebook Pixel Code - Ad 1-->
 <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', 'xxxxxxxxxxxxx12');
 fbq('track', "PageView");
 // Purchase
 // Track purchases or checkout flow completions (ex. landing on "Thank You" or confirmation page)
 fbq('track', 'Purchase', {value: '1.00', currency: 'USD'});
 </script>
 <noscript><img height="1" width="1" style="display:none"
 src="https://www.facebook.com/tr?id=xxxxxxxxxxxxx12&ev=PageView&noscript=1"
  /></noscript>
<!-- End Facebook Pixel Code -->

 <!-- Facebook Pixel Code - Ad 2-->
 <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', 'xxxxxxxxxxxxx34');
 fbq('track', "PageView");
 // Purchase
 // Track purchases or checkout flow completions (ex. landing on "Thank You" or confirmation page)
 fbq('track', 'Purchase', {value: '1.00', currency: 'USD'});

 </script>
 <noscript><img height="1" width="1" style="display:none"
 src="https://www.facebook.com/tr?id=xxxxxxxxxxxxx34&ev=PageView&noscript=1"
  /></noscript>
<!-- End Facebook Pixel Code -->

 <!-- Facebook Pixel Code - Ad 2-->
 <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', 'xxxxxxxxxxxxx56');
 fbq('track', "PageView");
 // Purchase
 // Track purchases or checkout flow completions (ex. landing on "Thank You" or confirmation page)
 fbq('track', 'Purchase', {value: '1.00', currency: 'USD'});
 </script>
 <noscript><img height="1" width="1" style="display:none"
 src="https://www.facebook.com/tr?id=xxxxxxxxxxxxx56&ev=PageView&noscript=1"
  /></noscript>
<!-- End Facebook Pixel Code -->

这样做吗?或者我需要做不同的事情,以便购买活动不会被发射4次。我正在使用Chrome的FB Pixel Helper插件,以确保所有像素都正在触发,但我收到一个错误,他们正在触发多次。

Is this the way to do it? Or do I need to do something different so that the Purchase event does not get fired 4 times. I am using the FB Pixel Helper plugin for Chrome to make sure all pixels are firing, but I am getting an error that they are firing multiple times.

将我做这样的事情?

 <!-- Facebook Pixel Code - ALL ADS-->
 <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', 'xxxxxxxxxxxxx12');
 fbq('init', 'xxxxxxxxxxxxx34');
 fbq('init', 'xxxxxxxxxxxxx56');
 fbq('track', "PageView");
 // Purchase
 // Track purchases or checkout flow completions (ex. landing on "Thank You" or confirmation page)
 fbq('track', 'Purchase', {value: '1.00', currency: 'USD'});
 </script>
 <noscript><img height="1" width="1" style="display:none"
 src="https://www.facebook.com/tr?id=xxxxxxxxxxxxx12&ev=PageView&noscript=1"
  /></noscript>
<!-- End Facebook Pixel Code -->


推荐答案

我遇到同样的问题,在任何地方找到解决方案。我挖了代码,发现一种方法可以用来称为addPixelId。在我的测试中,您可以在init之后使用,这将添加第二个ID。您跟踪的任何事件现在都将发送到这两个ID。例如:

I was running into the same problem and I couldn't find the solution anywhere. I dug into the code and found a method you can used called "addPixelId". In my testing, you can use this right after the "init", which will add a second ID. Any events you track will now send to both IDs. For example:

fbq('init', 'xxxxxxxxxxxxx12');
fbq('addPixelId', 'xxxxxxxxxxxxx34');
fbq('addPixelId', 'xxxxxxxxxxxxx56');
fbq('track', 'PageView');

唯一需要注意的事情是您跟踪的任何事件将被跟踪您所有的ID已经定义对我来说,这是非常好的,没有任何问题。

The only other thing to be aware of is any events you track will be tracked for all IDs that you have defined. It's been working fantastic for me, no issues whatsoever.

这篇关于如何在一个网页上放置多个Facebook跟踪像素?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆