Magento 1.5.1 CE 中的 Google Analytics 电子商务跟踪错误

发布于 2024-12-21 19:18:03 字数 2139 浏览 1 评论 0原文

从 1.4.2 升级到 1.5.1 后,我的谷歌分析电子商务跟踪无法正常工作。谷歌跟踪流量、访问者,甚至目标……但谷歌分析中的整个电子商务部分不起作用……

我在模板中更改了 googleanalytics.xml,正如我在此处阅读的一些线程一样,它没有改变任何内容。

然后我根据这篇文章创建了 ga.php 覆盖: http://magentist.com/ magento_help/magento-google-analytics-issues/

然而,谷歌分析可以工作,但分析中的电子商务跟踪不起作用。

当我进行购买时,我的成功页面的源代码在 body 标签结束之前给出了这种代码:

<!-- BEGIN GOOGLE ANALYTICS CODE -->
<script type="text/javascript">
//<![CDATA[
var _gaq = _gaq || [];

_gaq.push(['_setAccount', 'UA-XXXXXXX-X']);
_gaq.push(['_trackPageview']);

_gaq.push(["_setDomainName", "www.mydomain.comindex.php"]);
_gaq.push(["_setAllowHash", false]);


(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>
<!-- END GOOGLE ANALYTICS CODE -->    </div> 

如果您注意到的话,index.php 之前缺少正斜杠

_gaq.push(["_setDomainName", "www.mydomain.comindex.php"]); 

我不知道也许这就是问题所在,谁能告诉我请问我该如何解决?

我尝试了在谷歌中找到的所有解决方案,但没有成功:((

这是我的 ga.php 覆盖中的函数的样子:

<!-- BEGIN GOOGLE ANALYTICS CODE -->
<script type="text/javascript">
//<![CDATA[
var _gaq = _gaq || [];
' . $this->_getPageTrackingCode($accountId) . '
_gaq.push(["_setDomainName", "' . $this->getDomainName() . '"]);
_gaq.push(["_setAllowHash", false]);
' . $this->_getOrdersTrackingCode() . '

(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>
<!-- END GOOGLE ANALYTICS CODE --> 

我希望有一个解决方案。

提前谢谢你:))

After upgrading from 1.4.2 to 1.5.1 my google analytics ecommerce tracking isnt working. Google tracks traffic, visitors, even goals… but the whole ecommerce section in google analytics isnt working…

I changed in googleanalytics.xml in my template, as Ive read on some threads here, it didnt change anything.

Then I created ga.php override according to this post: http://magentist.com/magento_help/magento-google-analytics-issues/

and yet, google analytics works, but the ecommerce tracking in analytics doesnt work.

When I make a purchase, source code of my success page gives this kind of code right before the body tag closing:

<!-- BEGIN GOOGLE ANALYTICS CODE -->
<script type="text/javascript">
//<![CDATA[
var _gaq = _gaq || [];

_gaq.push(['_setAccount', 'UA-XXXXXXX-X']);
_gaq.push(['_trackPageview']);

_gaq.push(["_setDomainName", "www.mydomain.comindex.php"]);
_gaq.push(["_setAllowHash", false]);


(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>
<!-- END GOOGLE ANALYTICS CODE -->    </div> 

If you notice it, the forward slash is missing before the index.php

_gaq.push(["_setDomainName", "www.mydomain.comindex.php"]); 

I dont know maybe thats the problem, can anyone tell me please how to fix it?

I tried all the solutions I found in google without any success : ((

Here is how function looks like in my ga.php override:

<!-- BEGIN GOOGLE ANALYTICS CODE -->
<script type="text/javascript">
//<![CDATA[
var _gaq = _gaq || [];
' . $this->_getPageTrackingCode($accountId) . '
_gaq.push(["_setDomainName", "' . $this->getDomainName() . '"]);
_gaq.push(["_setAllowHash", false]);
' . $this->_getOrdersTrackingCode() . '

(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>
<!-- END GOOGLE ANALYTICS CODE --> 

I hope there is a solution for this.

Thank you in advance : ))

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

寂寞笑我太脆弱 2024-12-28 19:18:03

好吧,以防万一其他人遇到像我这样的问题...

我尝试了在网上找到的所有解决方案,但没有任何运气...今天我只需要安装另一个结帐扩展(我之前使用过“一步结帐”,它有问题),现在谷歌也跟踪电子商务交易...

所以,如果您遇到像我一样的问题,请确保扩展程序没有任何问题...

祝你好运! :))

Ok, just in case anyone else will have a problem like mine...

I tried all the solutions I found online without any luck... Today I just had to install another checkout extension ( I used "One Step Checkout" before and it had problems ) and now google tracks ecommerce transactions too...

so, if you'll have a problem like me, make sure the extension doesnt have any problems...

good luck! : ))

终陌 2024-12-28 19:18:03

正如代码上的仅供参考 - 我不熟悉 PHP,但是使用 Google Analytics,您希望您提到的行被读取:

_gaq.push(["_setDomainName", "mydomain.com"]);

所以摆脱 www.和index.php 完全一样。

另外,如果您只是在子域之间进行跟踪,而不是在两个不同域之间进行跟踪,则需要删除 _gaq.push(["_setAllowHash", false]);线。

Just as an FYI on the code - I'm not up with PHP, however with the Google Analytics, you want the line that you mentioned to read:

_gaq.push(["_setDomainName", "mydomain.com"]);

so get rid of the www. and the index.php completely.

Also, if you're just tracking between subdomains, and not tracking between two different domains, you want to remove the _gaq.push(["_setAllowHash", false]); line.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文