0
两次Magento的订单

四月份以来,订单被发送两次到Google Analytics,奇怪的是,一个是与格式9XXXXXXXXX确定,另一个是不罚款格式4XXX谷歌Analytics(分析)显示不同数量的

我不知道应该检查什么来防止这种情况。

我的网站是www.theprinterdepo.com,你可以自由地与签证号码创建演示订单41111111111111

enter image description here

此代码,我发现它在Ga.php

<?php 
/** 
* Magento 
* 
* NOTICE OF LICENSE 
* 
* This source file is subject to the Open Software License (OSL 3.0) 
* that is bundled with this package in the file LICENSE.txt. 
* It is also available through the world-wide-web at this URL: 
* http://opensource.org/licenses/osl-3.0.php 
* If you did not receive a copy of the license and are unable to 
* obtain it through the world-wide-web, please send an email 
* to [email protected] so we can send you a copy immediately. 
* 
* DISCLAIMER 
* 
* Do not edit or add to this file if you wish to upgrade Magento to newer 
* versions in the future. If you wish to customize Magento for your 
* needs please refer to http://www.magentocommerce.com for more information. 
* 
* @category Mage 
* @package  Mage_GoogleAnalytics 
* @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com) 
* @license  http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) 
*/ 


/** 
* GoogleAnalitics Page Block 
* 
* @category Mage 
* @package Mage_GoogleAnalytics 
* @author  Magento Core Team <[email protected]> 
*/ 
class Mage_GoogleAnalytics_Block_Ga extends Mage_Core_Block_Text 
{ 
    /** 
    * @deprecated after 1.4.1.1 
    * @see self::_getOrdersTrackingCode() 
    * @return string 
    */ 
    public function getQuoteOrdersHtml() 
    { 
     return ''; 
    } 

    /** 
    * @deprecated after 1.4.1.1 
    * self::_getOrdersTrackingCode() 
    * @return string 
    */ 
    public function getOrderHtml() 
    { 
     return ''; 
    } 

    /** 
    * @deprecated after 1.4.1.1 
    * @see _toHtml() 
    * @return string 
    */ 
    public function getAccount() 
    { 
     return ''; 
    } 

    /** 
    * Get a specific page name (may be customized via layout) 
    * 
    * @return string|null 
    */ 
    public function getPageName() 
    { 
     return $this->_getData('page_name'); 
    } 

    /** 
    * Render regular page tracking javascript code 
    * The custom "page name" may be set from layout or somewhere else. It must start from slash. 
    * 
    * @link http://code.google.com/apis/analytics/docs/gaJS/gaJSApiBasicConfiguration.html#_gat.GA_Tracker_._trackPageview 
    * @link http://code.google.com/apis/analytics/docs/gaJS/gaJSApi_gaq.html 
    * @param string $accountId 
    * @return string 
    */ 
    protected function _getPageTrackingCode($accountId) 
    { 
     $pageName = trim($this->getPageName()); 
     $optPageURL = ''; 
     if ($pageName && preg_match('/^\/.*/i', $pageName)) { 
      $optPageURL = ", '{$this->jsQuoteEscape($pageName)}'"; 
     } 
     return " 
_gaq.push(['_setAccount', '{$this->jsQuoteEscape($accountId)}']); 
_gaq.push(['_trackPageview'{$optPageURL}]); 
_gaq.push(['_trackPageLoadTime']); 
"; 
    } 

    /** 
    * Render information about specified orders and their items 
    * 
    * @link http://code.google.com/apis/analytics/docs/gaJS/gaJSApiEcommerce.html#_gat.GA_Tracker_._addTrans 
    * @return string 
    */ 
    protected function _getOrdersTrackingCode() 
    { 
     $orderIds = $this->getOrderIds(); 
     if (empty($orderIds) || !is_array($orderIds)) { 
      return; 
     } 
     $collection = Mage::getResourceModel('sales/order_collection') 
      ->addFieldToFilter('entity_id', array('in' => $orderIds)) 
     ; 
     $result = array(); 
     foreach ($collection as $order) { 
      if ($order->getIsVirtual()) { 
       $address = $order->getBillingAddress(); 
      } else { 
       $address = $order->getShippingAddress(); 
      } 
      $result[] = sprintf("_gaq.push(['_addTrans', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s']);", 
       $order->getIncrementId(), Mage::app()->getStore()->getFrontendName(), $order->getBaseGrandTotal(), 
       $order->getBaseTaxAmount(), $order->getBaseShippingAmount(), 
       $this->jsQuoteEscape($address->getCity()), 
       $this->jsQuoteEscape($address->getRegion()), 
       $this->jsQuoteEscape($address->getCountry()) 
      ); 
      foreach ($order->getAllVisibleItems() as $item) { 
       $result[] = sprintf("_gaq.push(['_addItem', '%s', '%s', '%s', '%s', '%s', '%s']);", 
        $order->getIncrementId(), 
        $this->jsQuoteEscape($item->getSku()), $this->jsQuoteEscape($item->getName()), 
        null, // there is no "category" defined for the order item 
        $item->getBasePrice(), $item->getQtyOrdered() 
       ); 
      } 
      $result[] = "_gaq.push(['_trackTrans']);"; 
     } 
     return implode("\n", $result); 
    } 

    /** 
    * Render GA tracking scripts 
    * 
    * @return string 
    */ 
    protected function _toHtml() 
    { 
     if (!Mage::helper('googleanalytics')->isGoogleAnalyticsAvailable()) { 
      return ''; 
     } 
     $accountId = Mage::getStoreConfig(Mage_GoogleAnalytics_Helper_Data::XML_PATH_ACCOUNT); 
     return ' 
<!-- BEGIN GOOGLE ANALYTICS CODE --> 
<script type="text/javascript"> 
//<![CDATA[ 
    (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\'; 
     (document.getElementsByTagName(\'head\')[0] || document.getElementsByTagName(\'body\')[0]).appendChild(ga); 
    })(); 

    var _gaq = _gaq || []; 
' . $this->_getPageTrackingCode($accountId) . ' 
' . $this->_getOrdersTrackingCode() . ' 

//]]> 
</script> 
<!-- END GOOGLE ANALYTICS CODE -->'; 
    } 
} 
+0

什么是你的谷歌分析JavaScript的样子? – Chris 2013-05-02 20:23:25

+0

这是magento,它应该自动插入它,我可以在哪里找到magento? – 2013-05-02 20:26:09

+0

@ChrisBain我发现了Ga.php,并在代码中插入了代码 – 2013-05-02 20:28:50

回答

1

我有同样的问题,解决方案很简单: 我已经安装并启用了一个模块进行跟踪,但忘记禁用Magento的核心跟踪能力(在Configuration> Sales> Google API下)。

3

的GA电子商务代码在您的订单确认页面上被调用两次。您列出的Ga.php中的代码似乎是以9XXXXXXXXX格式的订单号生成跟踪。

很难说出其他GA电子商务跟踪代码的来源,但如果您通过Chrome中的开发人员工具或Firefox中的Firebug检查页面,则应该能够看到其他跟踪代码在身体:

<script type="text/javascript">var _gaq = _gaq || []; 
_gaq.push(['_setAccount', 'UA-24813807-1']); 
_gaq.push(['_trackPageview']); 
_gaq.push(['_addTrans', 
'4598', 
'English', 
'34.3270', 
'0.0000', 
'19.4670', 
'Some City', 
'New York', 
'United States' 
]); 



_gaq.push(['_addItem','4598','Q1396A','Universal 21lb Basic Bond Paper Roll 24 inch x 150ft','','14.86', '1']); 
_gaq.push(['_trackTrans']); 
(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> 

也许看到在其中添加该代码将帮助您通过您的代码搜索,看看是否有您使用的恰好是将它添加一个模块的格式?

+0

我猜magento中的问题在它的success.phtml页面中,我想我可以从该文件中删除代码,因为它已经以某种方式注入了magento 。 – 2013-05-03 11:01:31