简体   繁体   English

Google Analytics(分析)未跟踪Magento 1.7中的转化

[英]Google Analytics not tracking conversions in Magento 1.7

I'm using Magento's built in Googleanalytics module which is working fine for page views, but not for conversions. 我使用的是Magento内置的Googleanalytics模块,该模块可以很好地用于页面浏览,但不能用于转换。 The account is set up fine on Google, but it's not adding the addTrans part in the checkout/onepage/success page. 该帐户在Google上设置良好,但未在checkout / onepage / success页面中添加addTrans部分。

I've done a lot of digging this morning, and found that the observer does observe the "checkout_onepage_controller_success_action" correctly, and does indeed run. 今天早上我做了很多挖掘工作,发现观察者确实观察到了“ checkout_onepage_controller_success_action”,并且确实在运行。 It does the following: 它执行以下操作:

$block = Mage::app()->getFrontController()->getAction()->getLayout()->getBlock('google_analytics');
    if ($block) {
        $block->setOrderIds($orderIds);
    }

I've done some echoing, and it does retrieve the block, and it also sets the order ids correctly. 我做了一些回显,并且确实检索到该代码块,并且它还正确设置了订单ID。 However, in the block itself, if I echo out $this->getOrderIds(); 但是,在块本身中,如果我回显了$ this-> getOrderIds(); its empty. 它是空的。

My next thought was that perhaps it could be using two GA blocks on the page, and maybe its passing the data to the first one but echoing the HTML of the 2nd one, but I've no clue how to start checking that! 我的下一个想法是,也许它可以在页面上使用两个GA块,并且可能将数据传递给第一个,但回显第二个的HTML,但是我不知道如何开始检查! The Googleanalytics.xml file only has one block it in, and I don't use that block name anywhere else! Googleanalytics.xml文件只有一个阻止,而我在其他任何地方都没有使用该阻止名!

Anyone experienced similar? 任何人都经历过类似? Or have any idea where I can go from here? 或有什么想法我可以从这里去吗?

EDIT: The Ga.php block includes the transaction code if $this->getOrderIds() returns an array, which it is not doing. 编辑:如果$ this-> getOrderIds()返回一个数组,则Ga.php块将包含事务代码,这是没有做的。 However, the observer is doing $block->setOrderIds($order_ids); 但是,观察者正在执行$ block-> setOrderIds($ order_ids);。 which is passing through an array containing an order id. 通过包含订单ID的数组传递。 So the observer is passing the ids to the block, and the block is receiving them (setting up a method of setBlockIds and echoing out the argument, does show the array), but when the block tries to access its own data, it's suddenly not there ($block->getData() returns an array of properties but there is no order_ids property). 因此观察者正在将id传递给块,并且块正在接收它们(设置setBlockIds的方法并回显参数,确实显示了数组),但是当块尝试访问自己的数据时,突然不那里($ block-> getData()返回属性数组,但没有order_ids属性)。

I also figured maybe it could be that its echoing the blocks HTML before setting the order id, so I added some variables in to check that and it's not that - its definitely setting the order_ids before trying to get them again, but its still not working! 我还想出了可能是它在设置订单ID之前回显了HTML块,所以我在其中添加了一些变量来检查它,并非如此-它肯定在尝试再次获取它们之前设置了order_ids,但仍然无法正常工作!

I'm completely stumped! 我完全陷入了困境! My only idea now is to modify the Ga.php block to use Magento's registry instead of it's own _data property, which is really not a nice way of doing it! 我现在唯一的想法是修改Ga.php块以使用Magento的注册表,而不是它自己的_data属性,这确实不是一个好方法!

I think i've been an utter tool. 我认为我一直是一个完全的工具。 Magento wasn't tracking conversions on the live site because I hadn't put the account code in the configuration part, but I had on my test site. Magento并没有在实时站点上跟踪转换,因为我没有在配置部分中输入帐户代码,但是在测试站点中。

I had previously put my own analytics code in the template, so I had tracked page views. 之前,我已经在模板中放入了自己的分析代码,因此我已经跟踪了页面浏览量。

When I saw no conversions (despite putting the account code in my test site), I started making orders on the test site and then viewing the source of the order success page. 当我没有看到任何转换时(尽管将帐户代码放入我的测试站点中),我开始在测试站点上下订单,然后查看订单成功页面的来源。 Firefox loads its source as a new request...which automatically goes to the empty basket page. Firefox会将其源作为新请求加载...自动转到空白篮页面。 So obviously, it wasn't showing the addTrans or anything, because it had already done that. 显然,它没有显示addTrans或任何内容,因为它已经完成了。

A quick check in firebug revealled it was working as it should. 快速检查萤火虫后发现它正在正常工作。

So in the end, after a day of searching, I had to change "No" to "Yes" in the admin, and type in the account code. 因此,最后,经过一天的搜索,我不得不在管理员中将“否”更改为“是”,然后输入帐户代码。 Great. 大。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM