javascript - Google Analytics 和 Google 跟踪代码管理器中的 AddThis 共享事件

标签 javascript google-analytics google-tag-manager addthis

我的网站上有 Google 跟踪代码管理器。

我将 addthis 代码硬编码到网站中(即不是通过 GTM 实现):

<script type="text/javascript">
  var addthis_config = {data_ga_property: 'UA-4035505-1'};
</script>
<script type="text/javascript" src="//s7.addthis.com/js/300/addthis_widget.js#pubid=XXXX" async="async"></script>

但是我在 Google Analytics 中没有看到任何 addThis 事件。根据他们的文档,我应该看到 eventCategory 设置为 addThis 的事件。然而他们不在那里。我不知道 addThis 如何将事件推送到 Google Analytics(即它是否尝试利用网站上的 analytics.js 代码或以某种方式使用自己的方法)。我怀疑它失败了,因为如果它确实尝试使用 analytics.js 代码,它就不能使用,因为 GA 标记是从 GTM 内触发的。

我还尝试在 addThis 配置中使用额外选项 data_ga_social: true,但我也没有看到 Google Analytics(分析)中弹出社交事件。

最佳答案

来自 addthis 文档:

"Note that AddThis doesn’t currently support Google’s Universal Analytics"

这似乎是他们的小部件代码的相关部分,实际上它仍然使用已弃用的 _gaq 对象:

 function x(e, t, n, r) {
        if ("facebook_unlike" != e && "google_unplusone" != e) {
            n = n || {};
            var o = n.data_ga_tracker,
                a = n.data_ga_property;
            if (a && ("object" == typeof window._gat && _gat._createTracker ? o = _gat._createTracker(a, "addThisTracker") : "object" == typeof window._gaq && _gaq._getAsyncTracker ? o = _gaq._getAsyncTracker(a) : window._gaq instanceof Array && _gaq.push([function() {
                    _ate.gat(e, t, n, r)
                }])), o && "string" == typeof o && (o = window[o]), !o && window.GoogleAnalyticsObject) {
                var i = window[window.GoogleAnalyticsObject];
                i.getAll && (o = i.getAll())
            }
            if (o && "object" == typeof o) {
                if ("more" == e || "settings" == e) return;
                var s = t || (r || {}).url || location.href,
                    c = e,
                    u = "share";
                c.indexOf("_") > -1 && (c = c.split("_"), u = c.pop(), u.length <= 2 && (u = "share"), c = c.shift()), 0 == s.toLowerCase().replace("https", "http").indexOf("http%3a%2f%2f") && (s = _duc(s));
                try {
                    n.data_ga_social && o._trackSocial && "google_plusone" != e ? o._trackSocial(c, u, r.url) : o._trackEvent ? o._trackEvent("addthis", e, s) : n.data_ga_social && "google_plusone" != e ? i("send", "social", c, u, s) : i("send", "event", "addthis", e, s)
                } catch (l) {
                    try {
                        o._initData && o._initData(), n.data_ga_social && o._trackSocial && "google_plusone" != e ? o._trackSocial(c, u, r.url) : o._trackEvent ? o._trackEvent("addthis", e, s) : n.data_ga_social && "google_plusone" != e ? i("send", "social", c, u, s) : i("send", "event", "addthis", e, s)
                    } catch (l) {}
                }
            }
        }
    }

关于javascript - Google Analytics 和 Google 跟踪代码管理器中的 AddThis 共享事件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36184937/

相关文章:

html - Google Analytics(分析)上的事件跟踪不起作用?

javascript - 为什么用户计时数据没有显示在 Google Analytics 中?

google-analytics - 在 Google 跟踪代码管理器中设置自定义页面标题

带有 iTunes 商店的 iOS 应用程序 - 获取货币代码(不是 priceLocal)

javascript - 使用 bootstrap3 modal、jquery 和 Rails 4 为我当前的模型创建父对象

javascript - 在 jQuery 中将单个未关闭的标签插入到元素中

xcode - 钛 iPhone 模组

google-analytics - Google Analytic Reporting和Google Tag Manager-重复计算访问

javascript - Highstock 标题和副标题重叠

javascript - 在laravel中使用ajax提交多个表单