Dealing with Optimizer(I)curl
1. Using cURL
http://code.google.com/apis/gdata/articles/using_cURL.html
Install curl
install this on my system
>sudo apt-get install curl
Getting an Authentication Token
the parameters of the command curl to google website
http://code.google.com/apis/accounts/docs/AuthForInstalledApps.html
>curl https://www.google.com/accounts/ClientLogin \
-d
[email protected] \
-d Passwd=your-password \
-d accountType=GOOGLE \
-d source=sillycat-3322-org \
-d service=analytics
Once succeed, we will get 3 import informations:
SID=
LSID=
Auth=
Accessing the API
curl --silent \
--header "Authorization: GoogleLogin auth=EUBBIacAAADK-kNxvRVmcQghpt3cqSMfEooLNMflLNIQqwgP9OrZS83gs-KSdTNeXhxsET7FYePWmaD8Vsy1V4LSUGMUP48Je2TO8OcjBj6HgAtPhiZeX-gKDfagZDK44j4n-Tkb44nhOnp2_QPSnBj3Z2vYwOEDjjG3Q53aQVC2132JKOuGh" \
-L "https://www.google.com/analytics/feeds/websiteoptimizer/experiments"
2 General Experiment Tasks
Request the experiment that you want to start.
>curl <BASE-OPTIONS> -L "https://www.google.com/analytics/feeds/websiteoptimizer/experiments/{experimentId}"
Save the returned XML description (e.g. as a file called experiment.xml).
Replace the current gwo:status from New to Running
After you've made this change, update the experiment.
>curl <BASE-OPTIONS> --request PUT --data "@experiment.xml" --header "Content-Type: application/atom+xml" -L "https://www.google.com/analytics/feeds/websiteoptimizer/experiments/{experimentId}"
Details in URL: http://code.google.com/intl/en/apis/analytics/docs/gwo/commonTasks.html
3.A/B Experiments
Create a new A/B experiment
Create a text file named experiment.xml that describes your experiment.
<entry xmlns='http://www.w3.org/2005/Atom'
xmlns:gwo='http://schemas.google.com/analytics/websiteoptimizer/2009'
xmlns:app='http://www.w3.org/2007/app'
xmlns:gd='http://schemas.google.com/g/2005'>
<title>My new A/B experiment</title>
<gwo:analyticsAccountId>XXXX</gwo:analyticsAccountId>
<gwo:experimentType>AB</gwo:experimentType>
</entry>
Then create this experiment by sending a POST with this file to the experiments feed:
>curl <BASE-OPTIONS> --request POST --data "@experiment.xml" --header "Content-Type: application/atom+xml" -L "https://www.google.com/analytics/feeds/websiteoptimizer/experiments"
Add a new page variation to an A/B experiment
Create a text file named pagevariation.xml that describes your new AB page variation:
<entry xmlns='http://www.w3.org/2005/Atom'
xmlns:gwo='http://schemas.google.com/analytics/websiteoptimizer/2009'
xmlns:app='http://www.w3.org/2007/app'
xmlns:gd='http://schemas.google.com/g/2005'>
<title>Page variation name</title>
<content>http://www.website.com/pagevariation.html</content>
</entry>
Then add the following page variation by sending a POST with this file to the experiment abpagevariations feed:
>curl <BASE-OPTIONS> --request POST --data "@pagevariation.xml" --header "Content-Type: application/atom+xml" -L "https://www.google.com/analytics/feeds/websiteoptimizer/experiments/{experimentId}/abpagevariations"
references:
http://code.google.com/intl/zh-CN/apis/analytics/docs/gwo/index.html
http://code.google.com/intl/en/apis/analytics/docs/gwo/index.html