facebook/google/twitter广告转化跟踪

google埋点

google分析有两种方式:
1 Universal Analytics (旧版)
2 Google Analytics (新版)
使用gtag和Google Tag Manager(TMS)谷歌代码跟踪管理器两种方式 区别
Universal Analytics 是 Google Analytics(分析)的早期版本,仅支持网站衡量功能。

创建账号后获取代码这是针对此媒体资源的全局网站代码 (gtag.js) 跟踪代码。请复制此代码,并将其作为第一个项目粘贴到您要跟踪的每个网页的 标记中。如果您的网页上已经有全局网站代码,则只需将以下代码段中的 config 行添加到现有的全局网站代码。事件代码

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-154795933-1"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-154795933-1');
</script>
<!-- Event snippet for Click to Store and Twitter conversion page In your html page,
add the snippet and call gtag_report_conversion when someone clicks on the chosen link or button. -->
<script>
function gtag_report_conversion(url) {
var callback = function() {
if (typeof(url) != 'undefined') {
window.location = url;
}
};
gtag('event', 'conversion', {
'send_to': 'AW-328469561/dBn9CJTm3N4CELmY0JwB',
'event_callback': callback
});
return false;
}
</script>
<div onclick="gtag_report_conversion('https://arkajp-test.ulugame.com/')"></div>
window.gtag("event", "conversion", {
send_to: "AW-328469561/SFBxCIqUtOICELmY0JwB"
});
//gtag_report_conversion是自定义事件,可以在a标签跳转,button按钮,或者img图片中埋点

可以使用 Google Tag Assistant 来确定自己的代码是否已正确植入。

google ads 和Google Analytics 是两个后台,一个是广告投放的埋点,一个是谷歌分析的埋点,可以将二者关联起来

twitter埋点

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
 <!-- twitter事件代码 -->
<script src="https://static.ads-twitter.com/oct.js" type="text/javascript"></script>
<!-- Twitter universal website tag code -->
<script>
! function(e, t, n, s, u, a) {
e.twq || (s = e.twq = function() {
s.exe ? s.exe.apply(s, arguments) : s.queue.push(arguments);
}, s.version = '1.1', s.queue = [], u = t.createElement(n), u.async = !0, u.src =
'//static.ads-twitter.com/uwt.js',
a = t.getElementsByTagName(n)[0], a.parentNode.insertBefore(u, a))
}(window, document, 'script');
// Insert Twitter Pixel ID and Standard Event data below
twq('init', 'o6gg2');
twq('track', 'PageView');
</script>
<!-- End Twitter universal website tag code -->

<!-- Twitter single-event website tag code -->
<script src="//platform.twitter.com/oct.js" type="text/javascript"></script>
<noscript>
<img height="1" width="1" style="display:none;" alt=""
src="https://analytics.twitter.com/i/adsct?txn_id=o6hm2&p_id=Twitter&tw_sale_amount=0&tw_order_quantity=0" />
<img height="1" width="1" style="display:none;" alt=""
src="//t.co/i/adsct?txn_id=o6hm2&p_id=Twitter&tw_sale_amount=0&tw_order_quantity=0" />
</noscript>
<!-- End Twitter single-event website tag code -->
事件
window.twttr.conversion.trackPid("o6guj", {
tw_sale_amount: 0,
tw_order_quantity: 0
});

facebook埋点

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
 <!-- 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', '2991050374466353');
fbq('track', 'PageView');
</script>
<noscript><img height="1" width="1" style="display:none"
src="https://www.facebook.com/tr?id=2991050374466353&ev=PageView&noscript=1" /></noscript>
<!-- End Facebook Pixel Code -->
事件
window.fbq("track", "ViewContent");

tiktok埋点

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
<script>
! function(w, d, t) {
w.TiktokAnalyticsObject = t;
var ttq = w[t] = w[t] || [];
ttq.methods = ["page", "track", "identify", "instances", "debug", "on", "off", "once", "ready", "alias",
"group", "enableCookie", "disableCookie"
], ttq.setAndDefer = function(t, e) {
t[e] = function() {
t.push([e].concat(Array.prototype.slice.call(arguments, 0)))
}
};
for (var i = 0; i < ttq.methods.length; i++) ttq.setAndDefer(ttq, ttq.methods[i]);
ttq.instance = function(t) {
for (var e = ttq._i[t] || [], n = 0; n < ttq.methods.length; n++) ttq.setAndDefer(e, ttq.methods[
n]);
return e
}, ttq.load = function(e, n) {
var i = "https://analytics.tiktok.com/i18n/pixel/events.js";
ttq._i = ttq._i || {}, ttq._i[e] = [], ttq._i[e]._u = i, ttq._t = ttq._t || {}, ttq._t[e] = +
new Date, ttq._o = ttq._o || {}, ttq._o[e] = n || {};
var o = document.createElement("script");
o.type = "text/javascript", o.async = !0, o.src = i + "?sdkid=" + e + "&lib=" + t;
var a = document.getElementsByTagName("script")[0];
a.parentNode.insertBefore(o, a)
};

ttq.load('C451BEEI9NESIEHM1HLG');
ttq.page();
}(window, document, 'ttq');
</script>