在Google Analytics和Google Tag Manager中添加此共享事件



我在网站上有谷歌标签管理器。

我已经将此代码硬编码到站点中(即未通过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>

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

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

来自添加此文档:

"请注意,AddThis目前不支持谷歌的通用分析"。

这似乎是他们小部件代码的相关部分,实际上它仍然使用不推荐使用的_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) {}
                }
            }
        }
    }

最新更新