Google 电子商务代码问题

发布于 2024-11-03 13:12:11 字数 1541 浏览 1 评论 0原文

此谷歌电子商务代码是否有任何问题。我们有大量交易,但没有显示 在电子商务中...

<script type="text/javascript">
        try{
          var pageTracker = _gat._getTracker("UA-XXXXXX-1");
      pageTracker._trackPageview();
          pageTracker._addTrans(
            "429",            // order ID - required
            "louiseh",  // affiliation or store name
            "11.65",           // total - required
            "3.15",           // shipping
            "Santa Clara",        // city
            "California",      // state or province
          );
    //Add each items in the order

          pageTracker._addItem(
            "429",  // order ID - necessary to associate item with transaction
            "99",           // SKU/code - required
            "Sandwich WrapIt!",        // product name
            "Home, Garden & Pets",   // category or variation
            "8.5",          // unit price - required
        "1",
          );
    //Now submit the transaction
    pageTracker._trackTrans(); //submits transaction to the Analytics server
       } catch(err) {}
    </script> 


<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
try {
var pageTracker = _gat._getTracker("UA-xxxxx-1");
pageTracker._trackPageview();
} catch(err) {}</script>

Is there any issue in this google ecommerce code. We had tons of transactions but none showing
up in the ecommerce...

<script type="text/javascript">
        try{
          var pageTracker = _gat._getTracker("UA-XXXXXX-1");
      pageTracker._trackPageview();
          pageTracker._addTrans(
            "429",            // order ID - required
            "louiseh",  // affiliation or store name
            "11.65",           // total - required
            "3.15",           // shipping
            "Santa Clara",        // city
            "California",      // state or province
          );
    //Add each items in the order

          pageTracker._addItem(
            "429",  // order ID - necessary to associate item with transaction
            "99",           // SKU/code - required
            "Sandwich WrapIt!",        // product name
            "Home, Garden & Pets",   // category or variation
            "8.5",          // unit price - required
        "1",
          );
    //Now submit the transaction
    pageTracker._trackTrans(); //submits transaction to the Analytics server
       } catch(err) {}
    </script> 


<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
try {
var pageTracker = _gat._getTracker("UA-xxxxx-1");
pageTracker._trackPageview();
} catch(err) {}</script>

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

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

发布评论

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

评论(1

_蜘蛛 2024-11-10 13:12:11

电子商务代码在 ga.js 脚本加载之前执行,因此 _gat 对象尚不可用。抛出了一个错误,但它没有显示在错误控制台中,因为它包含在 try/catch 块中。如果您重新排序脚本块,那么它应该可以工作:

<script type="text/javascript">
    var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
    document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
    try{
        var pageTracker = _gat._getTracker("UA-XXXXXX-1");
        pageTracker._trackPageview();
        pageTracker._addTrans(
        "429",            // order ID - required
        "louiseh",  // affiliation or store name
        "11.65",           // total - required
        "3.15",           // shipping
        "Santa Clara",        // city
        "California"      // state or province
    );

        //Add each items in the order
        pageTracker._addItem(
        "429",  // order ID - necessary to associate item with transaction
        "99",           // SKU/code - required
        "Sandwich WrapIt!",        // product name
        "Home, Garden & Pets",   // category or variation
        "8.5",          // unit price - required
        "1"
    );
        //Now submit the transaction
        pageTracker._trackTrans(); //submits transaction to the Analytics server
    } catch(err) {}
</script> 

The ecommerce code is being executed before the ga.js script is loaded so the _gat object isn't available yet. An error is being thrown but it's not being shown in the error console because it's enclosed in a try/catch block. If you reorder the script blocks then it should work:

<script type="text/javascript">
    var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
    document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
    try{
        var pageTracker = _gat._getTracker("UA-XXXXXX-1");
        pageTracker._trackPageview();
        pageTracker._addTrans(
        "429",            // order ID - required
        "louiseh",  // affiliation or store name
        "11.65",           // total - required
        "3.15",           // shipping
        "Santa Clara",        // city
        "California"      // state or province
    );

        //Add each items in the order
        pageTracker._addItem(
        "429",  // order ID - necessary to associate item with transaction
        "99",           // SKU/code - required
        "Sandwich WrapIt!",        // product name
        "Home, Garden & Pets",   // category or variation
        "8.5",          // unit price - required
        "1"
    );
        //Now submit the transaction
        pageTracker._trackTrans(); //submits transaction to the Analytics server
    } catch(err) {}
</script> 
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文