0%

h5页面集成fackback事件上报

基础代码

{your-pixel-id-goes-here}替换为实际的pixelID,将以下代码放在网页的<head></head>

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
<!-- Facebook Pixel Code -->
<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',
'https://connect.facebook.net/en_US/fbevents.js');
fbq('init', '{your-pixel-id-goes-here}');
fbq('track', 'PageView');
</script>
<noscript>
<img height="1" width="1" style="display:none"
src="https://www.facebook.com/tr?id={your-pixel-id-goes-here}&ev=PageView&noscript=1"/>
</noscript>
<!-- End Facebook Pixel Code -->

如果有其他事件上报,例如ViewContent,在基础代码的fbq('track', 'PageView');行后添加该事件上报:

1
2
fbq('track', 'PageView');
fbq('track', 'ViewContent'); // 新添加的事件
-------------本文结束感谢您的阅读-------------