我正在尝试使用谷歌分析 API 下载“用户定义”变量。登录正在工作,它正确显示了如下所示的正常请求,但我不知道如何提取用户定义的变量数据。
USER_EMAIL="my@email.tld" #Insert your Google Account email address here
USER_PASS="mypassword" #Insert your password here
TABLE_ID="ga:12345my_t_id" #Insert your table ID here (ie ga:1234)
googleAuth="$(curl https://www.google.com/accounts/ClientLogin -s \
-d Email=$USER_EMAIL \
-d Passwd=$USER_PASS \
-d accountType=GOOGLE \
-d source=curl-dataFeed-v2 \
-d service=analytics \
| awk /Auth=.*/)"
feedUri="https://www.google.com/analytics/feeds/data\
?ids=$TABLE_ID\
&start-date=2010-04-04\
&end-date=2011-07-07\
&dimensions=ga:source,ga:medium\
&metrics=ga:visits\
&sort=-ga:visits\
&filters=ga:medium%3D%3Dreferral\
&max-results=5\
&prettyprint=true"
curl $feedUri --silent \
--header "Authorization: GoogleLogin $googleAuth" \
--header "GData-Version: 2"
顺便说一下,用户定义的变量是完整的引用 URL。
编辑:我想通了,ga:userDefinedValue使用分析数据浏览器,如果你想要奖励,请添加评论!:
http://code.google.com/apis/analytics/docs/gdata/gdataExplorer.html