簡體   English   中英

使用OOcharts API獲取Google Analytics(分析)數據

[英]Use of OOcharts api to fetch google analytics data

您好,我正在使用oocharts插件來獲取CMS信息中心的Google Analytics(分析)統計信息,我無法理解我要怎么做?

這是我使用的默認代碼,其中之一是文件metric.html的訪問次數

<html>
<head>
</head>
<body>
    <h3>With JS</h3>
    Visits : <span id='metric'></span>

    <h3>With HTML Attributes</h3>
    Visits : <span data-oochart='metric' data-oochart-metric='ga:visits' data-oochart-start-date='30d' data-oochart-profile='{{ My Profile Id }}'></span>

    <script src='oocharts.js'></script>
    <script type="text/javascript">

        window.onload = function(){

            oo.setAPIKey("{{ My Key }}");

            oo.load(function(){

                var metric = new oo.Metric("{{ My profile Id }}", "30d");

                metric.setMetric("ga:visits");

                metric.draw('metric');

                document.getElementById('metric').value=metric;

                alert(metric);
            });
        };

    </script>
</body>

我了解完整的代碼,但是卻無法操縱數據,即無法回顯/打印該數據。 另外,當我檢查我的Firefox控制台以查看所有URL是否正確調用時,在調用api.oocharts.com時收到400錯誤的錯誤請求

有人可以告訴我在這種情況下應該怎么做嗎?

我只想在我的網站上回顯至少一個數據,例如visit:。

提前致謝!

您必須等待一段時間才能生效。 添加API密鑰后,它們的服務器可能沒有更新。

您需要將{{ profile ID }}替換為Google Analytics(分析)個人資料ID。 可以通過登錄到分析工具,單擊“管理員”,然后查看如下所示的URL來找到

' https://www.google.com/analytics/web/?hl=zh_CN#management/Settings/a5381475w10244833p10898655/ '

設定檔ID是網址中p后面的7位數字。 在這種情況下,配置文件ID為10898655

您還需要用您的OOCharts API替換{{ api key }} ,該API應該使用您的Google帳戶在OOCharts管理控制台中生成。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM