【问题标题】:Facebook 'Like' not showing up in Google AnalyticsFacebook 的“赞”未出现在 Google Analytics(分析)中
【发布时间】:2020-02-28 05:18:10
【问题描述】:

我正在尝试链接我页面上的 Facebook Like 按钮并将其与 Google Analytics 链接。 在执行 console.log 和 ga(send()) 'hitCallBack' 时,结果还可以。 然而,Facebook 的点赞并没有显示在我的 Google Analytics(分析)上的社交插件选项卡中。 注意:我正在本地主机上进行测试。

我的脚本:

<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-159331778-1"></script>
<script>
    window.dataLayer = window.dataLayer || [];
    function gtag(){dataLayer.push(arguments);}
    gtag('js', new Date());

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

<!-- Google Analytics -->
<script>
    (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
        (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
        m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
    })(window,document,'script','https://www.google-analytics.com/analytics.js','ga');

    ga('create', 'xxxxxxxxxxx', 'auto');
    ga('send', 'pageview');
</script>

<!-- Facebook Javascript SDK -->
<script>(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); js.id = id;
js.async = true;
js.src = "//connect.facebook.net/en_US/all.js#xfbml=1&appId=2854011081354723";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>

<script>
window.fbAsyncInit = function() {

    console.log("fbAsyncInit")
    FB.init({
        appId            : 'xxxxxxxxxxxxxxx',
        autoLogAppEvents : true,
        xfbml            : true,
        version          : 'v6.0'

    });console.log("FB.init works");
    var currentPage = $(document).attr('title');
    FB.Event.subscribe('edge.create',function(href,widget) {
        ga('send', {
            'hitType': 'social',
            'socialNetwork': 'Facebook',
            'socialAction': 'Like',
            'socialTarget': href,
            'page': currentPage,
            'hitCallback': function() {
                alert('Callback success');
            }
            });
        console.log("FB Like Sent");
    });        
};
</script> 

还有我的 Facebook Like div:

<div class="fb-like" data-href="xxxxxxxxxx" data-width="" data- 
layout="button_count" data-action="like" data-size="large" data-share="false"></div>
</div>

页面浏览量通过但不是 facebook 之类的信息。 需要帮助。 谢谢!

【问题讨论】:

  • 你看到 FB Like Sent 的 console.log 了吗?
  • 是的。 console.log 出现

标签: javascript facebook google-analytics facebook-like


【解决方案1】:

我看到您正在分别实施 Google Analytics 和 Facebook Analytics。我的第一个建议是通过 Google Tag Manager 实施 Google Analytics。其次,从 HTML 中删除 Google Analytics。使用 JavaScript (jQuery),您可以向 Google 跟踪代码管理器添加推送事件的“点击侦听器”,例如 ButtonClick(包含有关按钮点击的详细信息)。通过 Google Tag Manager,您可以将详细信息发送到 Google Analytics。

【讨论】:

    猜你喜欢
    • 2022-07-29
    • 2014-04-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-07-10
    相关资源
    最近更新 更多