Google Analytics Ecommerce Tracking “No HTTP Respo

2019-08-07 14:16发布

Following the documentation found here: https://developers.google.com/analytics/devguides/collection/gajs/

I have made a simplest case in an empty html file as such:

<script type="text/javascript">
    var _gaq = _gaq || [];
    _gaq.push(['_setAccount', 'UA-XXXX-2']);
    _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>

When I load the page in Chrome with the Google Tag Assistant plugin it says "No HTTP Response Detected" and I all I see in the Developer Tools network tab is the html file load and the ga.js script being downloaded from google. I get the same result in IE, but when I use Firefox I can see the it trying to get __utm.gif from Google which is how I understand that it should work.

I see no errors in the console, why wouldn't this work in IE and Chrome?

Here is the entire html:

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title>GA Test</title>
        <script type="text/javascript">
            var _gaq = _gaq || [];
            _gaq.push(['_setAccount', 'UA-X-2']);
            _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>
    </head>
    <body>
        <p>Testing GA</p>
    </body>
</html>

2条回答
太酷不给撩
2楼-- · 2019-08-07 14:50

May be this happens, if you are using tracking code at the locale HTML file(as you said, that website is not live yet).

So,

  1. This tracking code will work, when you publish it to live domain;
  2. May be if you add string _gaq.push(['_setDomainName', 'none']); before string _gaq.push(['_trackPageview']); in your locale HTML, it will work for you and will send HTTP-response.
查看更多
虎瘦雄心在
3楼-- · 2019-08-07 14:51

I actually would recommend that before you implement this tracking, that you go ahead and upgrade to Universal Analytics. The e-commerce tracking should be easier to set up and with classic analytics already being depreciated, this seems to be the step that would be best for you. This link shows a bit on how much easier it can be.

https://developers.google.com/analytics/devguides/collection/analyticsjs/ecommerce

查看更多
登录 后发表回答