简体   繁体   English

使用自定义日期创建Google Analytics(分析)信息中心

[英]Creating Google Analytics Dashboard With Custom Dates

I am creating a dashboard using Google Analytics Data using JSON webservice. 我正在使用JSON Web服务使用Google Analytics(分析)数据创建仪表板。 What it does is when I enter the From Date & To Date, Google analytics will trigger a query according to that dates and reply with a response. 它的作用是,当我输入“起始日期和截止日期”时,Google Analytics(分析)将根据该日期触发查询并回复响应。

According to that response the chart will be drawn. 根据该响应,将绘制图表。

Updated 更新

Two dates taken from a HTML form & it's in below. 以下是从HTML表单中提取的两个日期。

Dashboard.html Dashboard.html

<script type="text\javascript src="js/jquerysoap.js"></script>
<script type="text/javascript" src="js/script.js"></script>

</head>
<form action="" method="post">
    From Date : <input type="text" id="from_date" />
    To Date : <input type="text" id="to_date" />
    <input type="submit" value="Submit" class="submit_button" onClick="getVaria(); return false" />
    </form>

These entered dates will be grabbed by some JavaScript functions in the Script.js file. 这些输入的日期将由Script.js文件中的某些JavaScript函数获取。

Script.js 的script.js

function retStartDate(){

var strStartDate = document.getElementById("from_date").value;

alert("Start date " + strStartDate);

return strStartDate;

}

function retEndDate(){

var strEndDate = document.getElementById("to_date").value;

alert("End date " + strEndDate);

return strEndDate;

}

These 2 dates will then paaased to the chart query to fraw the chart as like the below. 然后,这两个日期将停顿到图表查询中,如下图所示。

function getVaria(){

/* Chart query.*/ / *图表查询。* /

var strWsUrl = 'https://www.googleapis.com/analytics/v3/data/ga?ids=ga%3A76546294&  dimensions=ga%3Asource&metrics=ga%3Ausers&filters=ga%3Asource!%3D(direct)&sort=-ga%3Ausers&start-date= ' + retStartDate() + ' &end-date= ' + retEndDate() + ' &max-results=10';

alert(strWsUrl);

return strWsUrl;

}    

The source code is above. 上面的源代码。

I am able to pass the 2 dates to the query. 我能够将2个日期传递给查询。 Then I cannot find out a way to get the response from JSON and so on. 然后我找不到从JSON等获得响应的方法。 I'm using JavaScript on this one because it gives more mobility than server side scripting. 我在这上面使用了JavaScript,因为它比服务器端脚本提供了更多的移动性。 So could you someone give me a clue for that? 那么,有人可以给我一个线索吗?

Thanks & regards, Chiranthaka 感谢和问候,Chiranthaka

This error is generated because I used the 'return' value instead of the JavaScript Function() name. 生成此错误是因为我使用了“ return”值而不是JavaScript Function()名称。 The correct one is at the below. 正确的是在下面。

var strWsUrl =

' https://www.googleapis.com/analytics/v3/data/ga?ids=ga%3A76546294&dimensions= '+ 'ga%3Asource&metrics=ga%3Ausers&sort=-ga%3Ausers&start-date='+retStartDate()+'&end-date='+retEndDate()+'&max-results=10'; ' https://www.googleapis.com/analytics/v3/data/ga?ids=ga%3A76546294&dimensions='+'ga%3Asource&metrics = ga%3Ausers&sort = -ga%3Ausers&start-date ='+ retStartDate()+' &结束日期= '+ retEndDate()+' &最大结果= 10' ;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM