为什么我不能要求使用analytics.js的增强型电子商务“ ec”插件?

时间:2019-05-26 08:42:38

标签: javascript google-analytics

我已经按照Google Analytics(分析)指南使用增强型电子商务插件来运行增强型电子商务命令,但它一直在说要等待ec插件完成。

Initializing Google Analytics.
analytics_debug.js:15 Loading resource for plugin: ec
analytics_debug.js:15 Loading script: "https://www.google-analytics.com/plugins/ua/ec.js"
analytics_debug.js:15 Running command: ga("create", "UA-xxxx-x", "auto")
analytics_debug.js:15 Creating new tracker: t0
analytics_debug.js:15 Auto cookieDomain found: "none"
analytics_debug.js:15 Running command: ga("require", "ec")
analytics_debug.js:15 Waiting on require of "ec" to be fulfilled.
analytics_debug.js:15 Registered new plugin: ga(provide, "render", Function)
analytics_debug.js:15 Running command: ga("require", "ec")
analytics_debug.js:15 Waiting on require of "ec" to be fulfilled.

我试图等待它实现,并尝试了不同的实现方式,但是它不起作用

<script>
        (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
        (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
        m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
        })(window,document,'script','https://www.google-analytics.com/analytics_debug.js','ga');

        ga('create', 'UA-140004926-1', 'auto');
        ga('require', 'ec');
        ga('ec:addImpression', {
          'id': 'P12345',                   // Product details are provided in an impressionFieldObject.
          'name': 'Android Warhol T-Shirt',
          'category': 'Apparel/T-Shirts',
          'brand': 'Google',
          'variant': 'black',
          'list': 'Search Results',
          'position': 1                     // 'position' indicates the product position in the list.
        });

        ga('ec:addImpression', {
          'id': 'P67890',
          'name': 'YouTube Organic T-Shirt',
          'category': 'Apparel/T-Shirts',
          'brand': 'YouTube',
          'variant': 'gray',
          'list': 'Search Results',
          'position': 2
        });

        ga('send', 'pageview'); 

        </script>

0 个答案:

没有答案