Facebook 小游戏 统计接入问题


Facebook 小游戏 域名限制

  • 接入TalkingData时,会报错误如下:
1
Refused to load the script 'https://h5.talkingdata.com/g/h5/v1/xxxxxxx' because it violates the following Content Security Policy directive: "script-src 'self' 'unsafe-inline' 'unsafe-eval' *.facebook.com connect.facebook.net cdn.mixpnl.com *.google-analytics.com web.localytics.com *.googletagmanager.com blob: *.cloudfront.net *.amazonaws.com *.googleapis.com *.firebaseapp.com *.firebaseio.com *.8686c.com *.cncovs.com *.aliyun.com *.aliyuncs.com *.wsdvs.com *.console.re *.kunlunar.com *.layabox.com *.windows.net *.msecnd.net *.anysdk.com cdn.trackjs.com cdn.firebase.com *.kochava.com *.akamaized.net *.cocos.com *.hinet.net ".

所以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
*.facebook.com 
connect.facebook.net
cdn.mixpnl.com
*.google-analytics.com
web.localytics.com
*.googletagmanager.com
*.cloudfront.net
*.amazonaws.com
*.googleapis.com
*.firebaseapp.com
*.firebaseio.com
*.8686c.com
*.cncovs.com
*.aliyun.com
*.aliyuncs.com
*.wsdvs.com
*.console.re
*.kunlunar.com
*.layabox.com
*.windows.net
*.msecnd.net
*.anysdk.com
cdn.trackjs.com
cdn.firebase.com
*.kochava.com
*.akamaized.net
*.cocos.com
*.hinet.net
  • 可以接入 Google Analytics(分析)

官网步骤如下:

将以下代码段粘贴到您网站的每个网页的 标记之后,并且紧挨着该标记放置。将 GA_TRACKING_ID 替换为您自己的 Google Analytics(分析)跟踪 ID:

1
2
3
4
5
6
7
8
9
<!-- Global Site Tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=GA_TRACKING_ID"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());

gtag('config', 'GA_TRACKING_ID');
</script>

要验证跟踪代码是否正常工作,请访问您的网站,并检查您的这次访问是否已在实时报告中记录。

  • 跟踪 Google Analytics(分析)事件

https://developers.google.com/analytics/devguides/collection/gtagjs/events

下表列出了默认的 Google Analytics(分析)事件、相应默认类别和默认标签类型(如果提供)。对于未在此表中列出的事件名称(例如您创建的任意事件名称),默认类别为“engagement”,默认标签为“not set”。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
事件名称	默认类别	默认标签类型
add_payment_info ecommerce
add_to_cart ecommerce
add_to_wishlist ecommerce
begin_checkout ecommerce
checkout_progress ecommerce
generate_lead engagement
login engagement method
purchase ecommerce
refund ecommerce
remove_from_cart ecommerce
search engagement search_term
select_content engagement content_type
set_checkout_option ecommerce
share engagement method
sign_up engagement method
view_item engagement
view_item_list engagement
view_promotion engagement
view_search_results engagement search_term