del*_*oki 4 javascript google-analytics web
我无法使用javascript从Google Analytics API获取数据.我似乎无法获取任何东西,但让我们说它像浏览量一样基本.
我正在使用Analytics.js
这是我用来连接GA API的代码:
(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','//www.google-analytics.com/analytics.js','ga');
    ga('create', 'XXX', 'example.com');
    ga('send', 'pageview');
那么我如何获得网页浏览量呢?我尝试使用此代码,但它返回undefined:
ga(function() {
      var tracker = ga.getByName('t0');
      alert(tracker.get('page'));
    });
Analytics.js是一种跟踪API.它只是跟踪/发送数据到Google Analytics.
要从Google Analytics检索数据,您需要使用其他API.查找Reporting API.
https://developers.google.com/analytics/devguides/reporting/
| 归档时间: | 
 | 
| 查看次数: | 5689 次 | 
| 最近记录: |