2

我在一页中有两个 Google 分析事件。我只想要一个 Google 分析事件。无论如何我可以删除一个,所以当我打开该页面时,只能看到一个谷歌分析。

<script type="text/javascript">
    var _gaq = _gaq || [];
    _gaq.push(['_setAccount', 'UA-XXXXXXXX-1']);
    _gaq.push(['_trackPageview']);

    (function () {
        var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
        ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
        var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
    })();
</script>

和,

<script type=text/java-script>
    var _gaq = _gaq || [];
    _gaq.push(['_setAccount', 'UA-XXXXXXXX-1']);
    _gaq.push(['_trackPageview']);
    _gaq.push(['_addTrans','7000004','380194','99.99','7.27','20','Richfield','MN','US']);
    _gaq.push(['_addItem','7000004','38361','Power Shovel (38361)','','99.99','1']);
    _gaq.push(['_trackTrans']); //submits transaction to the Analytics servers
    (function() {
        var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
        ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + 'Google-analytics.com/ga.js';
        var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
    })();
</script>

我想删除第二个。

非常感谢

4

1 回答 1

1

如果我正确理解了您的问题,那么这应该很容易解决。

看起来您有两个相同的块调用 Google Analytics(在帐户 UA-31277529-1 上),第一个只是 Google 提供的原版添加到页面代码。

第二个块包括相同的初始化,但也将一些额外的信息推送到分析(电子商务跟踪?)。从本质上讲,由于第一个块,您在设置和页面跟踪中获得了冗余。

So, I'm assuming that you want to both:

  • track page visitors via Analytics;
  • and track the additional eCommerce attributes you're pushing.

Then, all you need to do is remove the first code block and use only the second one:

<script type=text/java-script>
    var _gaq = _gaq || [];
    _gaq.push(['_setAccount', 'UA-31277529-1']);
    _gaq.push(['_trackPageview']);
    _gaq.push(['_addTrans','7000004','380194','99.99','7.27','20','Richfield','MN','US']);
    _gaq.push(['_addItem','7000004','38361','Power Shovel (38361)','','99.99','1']);
    _gaq.push(['_trackTrans']); //submits transaction to the Analytics servers
    (function() {
        var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
        ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + 'Google-analytics.com/ga.js';
        var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
    })();
</script>

This will still track your page views, but will also track your eCommerce objects, which should all occur in one, single 'fire'.

于 2013-05-30T15:54:46.523 回答