简体   繁体   English

设定Google Analytics(分析)magento

[英]setup google analytics magento

Hi i have added a Google analytic account number in the admin,do i also need to add the Google tracking code in the files to track,in Google it still showing the 嗨,我已经在管理员中添加了Google分析帐号 ,我是否还需要在要跟踪的文件中添加Google跟踪代码,在Google中它仍然显示

The Google Analytic tracking code has not been detected on your website's home page 在您网站的主页上未检测到Google Analytic跟踪代码

please tell me how can i setup the Google analytic to my site. 请告诉我如何设置我网站的Google分析。

<script type="text/javascript">

  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'xxxxxxxx']);//fake
  _gaq.push(['_setDomainName', 'fake.com']);//fake
  _gaq.push(['_setAllowLinker', true]);
  _gaq.push(['_trackPageview']);

  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://' : 'http://') + 'stats.g.doubleclick.net/dc.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  })();

</script>

do i need to add this type of code in files 我需要在文件中添加这种类型的代码吗

Once the account has been set up in the admin the JS code should be outputted automatically. 在管理员中设置帐户后,应自动输出JS代码。 Possible reasons why it still is not are: 它仍然不是的可能原因是:

  1. Output is disabled for the "Google Analytics" module. “ Google Analytics(分析)”模块的输出已禁用。 Check under "Configuration"=>"Advanced" if that is the case. 如果是这样,请在“配置” =>“高级”下进行检查。
  2. Some layout update removes the block "google_analytics". 某些布局更新删除了“ google_analytics”块。 Search your XML layout updates for lines containing "google_analytics" - there may be a "remove" node with this name. 在XML布局更新中搜索包含“ google_analytics”的行-可能存在一个具有该名称的“删除”节点。
  3. The template file "googleanalytics/ga.phtml" is unreadable or missing 模板文件“ googleanalytics / ga.phtml”不可读或丢失
  4. The setting "Cookie Restriction Mode" set to "yes" under "Web" will also prevent the code output 在“ Web”下将“ Cookie Restriction Mode”设置为“ yes”也会阻止代码输出

If you have Firefox installed on your machine then install the Plugin for Firebug called "Omnibug", you can find it on the developer's site. 如果您的计算机上安装了Firefox,然后安装名为“ Omnibug”的Firebug插件,则可以在开发人员的站点上找到它。

When you open that tab when browsing your site you will see a number of requests being made to Google. 在浏览网站时打开该标签时,您会看到许多对Google的请求。 If there are no requests showing up then Magento is not configured correctly to output the GATC (Google Analytics Tracking Code). 如果没有出现任何请求,则说明Magento配置不正确,无法输出GATC(Google Analytics(分析)跟踪代码)。

Also, check out the Magento docs for setting up GATC 另外,请查看Magento文档以设置GATC

Many times, GA takes up to 24 hours to show the data and update the tracking code status. GA最多需要24小时才能显示数据并更新跟踪代码状态。 Can you wait for some time and see if the hits start appearing? 您可以等待一段时间,看看点击数是否开始出现吗?

A quick way to check this can be to try the realtime report and see if it is showing any data. 一种快速的检查方法是尝试实时报告,看看它是否显示任何数据。

I spent multiple days trying to figure this problem out, and tried lots of different solutions. 我花了很多天试图解决这个问题,并尝试了许多不同的解决方案。 Apparently there are a lot of things that can keep Google Analytics from working on Magento. 显然,有很多事情可以阻止Google Analytics(分析)在Magento上运行。 Oleg's advice was very good and fairly comprehensive and covers most of the answers I found. Oleg的建议非常好,相当全面,涵盖了我找到的大多数答案。 It did miss one of the explanations, though. 但是,它确实错过了其中一种解释。

Apparently, between version 1.3 and 1.4 Magento switched how it handled Google Analytics. 显然,在版本1.3和1.4之间,Magento切换了其处理Google Analytics(分析)的方式。 If you had a copy of any of any of the below in your custom template: 如果您的自定义模板中有以下任何内容的副本:

1column.phtml
2columns-left.phtml
2columns-right.phtml
3columns.phtml 

Then you need to add <?php echo $this->getChildHtml('after_body_start') ?> right above <div class="wrapper"> in any of above listed files that exist in your customized template. 然后,您需要在自定义模板中存在的上述任何文件中的<div class="wrapper">上方的正上方添加<?php echo $this->getChildHtml('after_body_start') ?> The location of the files will be in a directory like this: app/design/frontend/CustomGroup/Custom/template/page/ 文件的位置将在这样的目录中:app / design / frontend / CustomGroup / Custom / template / page /

Additionally, you may need to add two entries to your page.xml file in the app/design/frontend/CustomGroup/Custom/layout folder: 此外,您可能需要在app / design / frontend / CustomGroup / Custom / layout文件夹中的page.xml文件中添加两个条目:

<block type="core/text_list" name="after_body_start" as="after_body_start" translate="label">
     <label>Page Top</label>
</block>

<block type="page/html_notices" name="global_notices" as="global_notices" template="page/html/notices.phtml" />

The two entries should be placed right above the "header" block. 这两个条目应放在“标题”块的正上方。

The credit for this solution goes to those who replied in this thread and to two posters on the Magento forum. 此解决方案的功劳归功于在此主题中做出答复的人以及Magento论坛上的两个张贴者。 If you look at the posts by Ross and ceefour, you will see the solution that I have copied here described. 如果您查看Ross和ceefour的文章,您将看到我在此处复制的解决方案。 Here is a link: http://www.magentocommerce.com/boards/viewthread/23325/P45/#t240114 这是一个链接: http : //www.magentocommerce.com/boards/viewthread/23325/P45/#t240114

Also, I wanted to note that you can potentially find out whether Google Analytics is in use if you search for the word "GoogleAnalytics" in your page source. 另外,我想指出,如果您在页面源中搜索“ GoogleAnalytics”一词,则有可能可以发现是否正在使用Google Analytics(分析)。 In my case, it wasn't present until I followed the above steps. 就我而言,它不存在,直到我按照上述步骤进行。 As stated above, Omnibug also works well and may be a more certain test. 如上所述,Omnibug也可以很好地工作,并且可能是更确定的测试。

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

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