I'm trying to download the 'User Defined' variables using the google analytics API. The login is working and it properly shows normal requests like the one below, but I can't figure out how to extract the user defined variable data.
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开发者_如何学JAVA"
The user defined variable is the complete referral URL by the way.
EDIT: I FIGURED IT OUT, ga:userDefinedValue using the analytics data explorer, add a comment if you want the reward!:
http://code.google.com/apis/analytics/docs/gdata/gdataExplorer.html
This is being deprecated.
You should use ga:customVarName(n)
精彩评论