This document describes how to perform basic Website Optimizer tasks using the API. These examples use the command line tool cURL to access the API, but the basic approach is the same regardless of the tool or client library you are using to access the API. For more information on cURL and how to use it, see the Quick Start section.
Rather than repeat the authorization and version header info (which are the same for each example), we include a placeholder <BASE-OPTIONS> tag that you should replace with the following options:
--silent \ --header "GData-Version: 2.0" \ --header "Authorization: GoogleLogin auth=EUBBIac....Q53aQVC2132JKOuGh" \
Replace the Authorization token with the one that you received from ClientLogin (see the Quick Start section).
Google Data-Version: 2.0 is required if you wish to update, insert, or delete experiments. If you omit this, you will get version 1.0 of the API which does not have the gd:etags required to send update requests
Starting an experiment involves the following steps.
1) Request the experiment that you want to start.
curl <BASE-OPTIONS> -L "https://www.google.com/analytics/feeds/websiteoptimizer/experiments/{experimentId}"
where {experimentId} is replaced with the experiment
ID of the experiment.
2) Save the returned XML description (e.g. as a file called experiment.xml).
It should look similar to the following:
<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'
gd:etag='W/"A0UGRn47eCp7ImA9WxNSGUw."'>
<id>http://www.google.com/analytics/feeds/websiteoptimizer/experiments/619581</id>
<updated>2009-09-02T12:20:27.000-07:00</updated>
<app:edited>2009-09-02T12:20:27.000-07:00</app:edited>
<title>New experiment</title>
<link rel='alternate' type='text/html' href='http://www.google.com/websiteoptimizer' />
<link rel='self' type='application/atom+xml' href='http://www.google.com/analytics/feeds/websiteoptimizer/experiments/619581' />
<gwo:controlScript>...</gwo:controlScript>
<gwo:conversionScript>...</gwo:conversionScript>
<gwo:experimentType>Multivariate</gwo:experimentType>
<gwo:numCombinations>8</gwo:numCombinations>
<gwo:numSections>2</gwo:numSections>
<gwo:status>New</gwo:status>
<gwo:trackingScript>...</gwo:trackingScript>
</entry>
3) Replace the current gwo:status with
the following entry.
<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'>
...
<gwo:status>Running</gwo:status>
...
</entry>
The remaining fields can be deleted since they will be ignored.
4) 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}"
If successful, the update returns the experiment. You can verify that the
experiment was started by reading the gwo:status contents in the
returned experiment. You can also pause experiments with this method (or you
can just set the gwo:status to
Paused.
Note: You cannot launch experiments that have fewer than 2 combinations.
1) Request the experiment that you wish to update.
curl <BASE-OPTIONS> -L "https://www.google.com/analytics/feeds/websiteoptimizer/experiments/{experimentId}"
2) Save the returned XML description (e.g. as a file called experiment.xml).
3) Make the desired edits. Each entry has a special gd:etag which
is used to keep track of the current version.
4) After you've made the changes, 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}"
As long as the entry has not been updated on the server prior to your initial
request (i.e., as long as the gd:etag matches), the update should
succeed. If the experiment has been previously updated, then your update request
will fail.
curl <BASE-OPTIONS> -L "https://www.google.com/analytics/feeds/websiteoptimizer/experiments/{experimentId}"
Multivariate experiments have sections (gwo:numSections),
whereas A/B experiments have page variations (gwo:numAbPageVariations).
A multivariate experiment looks similar to the following:
<?xml version='1.0' encoding='UTF-8'?>
<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'
gd:etag='W/"DUAARn47eCp7ImA9WxJWFkU."'>
<id>http://www.google.com/analytics/feeds/websiteoptimizer/experiments/48172</id>
<updated>2009-06-22T09:22:27.000-07:00</updated>
<app:edited>2009-06-22T09:22:27.000-07:00</app:edited>
<title>Sample multivariate experiment</title>
<link rel='alternate' type='text/html' href='http://www.google.com/websiteoptimizer'/>
<link rel='self' type='application/atom+xml' href='http://www.google.com/analytics/feeds/websiteoptimizer/experiments/48172'/>
<gwo:analyticsAccountId>1234</gwo:analyticsAccountId>
<gwo:controlScript>...</gwo:controlScript>
<gwo:conversionScript>...</gwo:conversionScript>
<gwo:experimentId>48172</gwo:experimentId>
<gwo:experimentType>Multivariate</gwo:experimentType>
<gwo:numCombinations>12</gwo:numCombinations>
<gwo:numSections>3</gwo:numSections>
<gwo:status>Running</gwo:status>
<gwo:trackingScript>...</gwo:trackingScript>
</entry>
An A/B experiment looks similar to this example:
<?xml version='1.0' encoding='UTF-8'?>
<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'
gd:etag='W/"D0cESH47eCp7ImA9WxVQEE0."'>
<id>http://www.google.com/analytics/feeds/websiteoptimizer/experiments/364738</id>
<updated>2009-01-26T13:23:29.000-08:00</updated>
<app:edited>2009-01-26T13:23:29.000-08:00</app:edited>
<title>Sample A/B experiment</title>
<link rel='alternate' type='text/html' href='http://www.google.com/websiteoptimizer'/>
<link rel='self' type='application/atom+xml' href='http://www.google.com/analytics/feeds/websiteoptimizer/experiments/364738'/>
<gwo:analyticsAccountId>1234</gwo:analyticsAccountId>
<gwo:controlScript>...</gwo:controlScript>
<gwo:conversionScript>...</gwo:conversionScript>
<gwo:experimentId>364738</gwo:experimentId>
<gwo:experimentType>AB</gwo:experimentType>
<gwo:numAbPageVariations>2</gwo:numAbPageVariations>
<gwo:numCombinations>2</gwo:numCombinations>
<gwo:status>New</gwo:status>
<gwo:trackingScript>...</gwo:trackingScript>
</entry>
curl <BASE-OPTIONS> -L "https://www.google.com/analytics/feeds/websiteoptimizer/experiments"
This command returns a feed response similar to the following:
<?xml version='1.0' encoding='utf-8'?>
<feed 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:openSearch='http://a9.com/-/spec/opensearch/1.1/'
xmlns:gd='http://schemas.google.com/g/2005'
gd:etag='W/"CEQHR347eCp7ImA9WxNREEs."'>
<id>http://www.google.com/analytics/feeds/websiteoptimizer/experiments/</id>
<updated>2009-09-04T04:05:36.000-07:00</updated>
<title>Experiment list for myemail@gmail.com</title>
<link rel='self' type='application/atom+xml'
href='http://www.google.com/analytics/feeds/websiteoptimizer/experiments/' />
<author>
<name>Google Analytics / Website Optimizer</name>
</author>
<generator version='1.0'>Google Analytics</generator>
<openSearch:totalResults>2</openSearch:totalResults>
<openSearch:startIndex>1</openSearch:startIndex>
<openSearch:itemsPerPage>2</openSearch:itemsPerPage>
<entry gd:etag='W/"DUAARn47eCp7ImA9WxJWFkU."'>
<id>http://www.google.com/analytics/feeds/websiteoptimizer/experiments/48172</id>
<updated>2009-06-22T09:22:27.000-07:00</updated>
<app:edited>2009-06-22T09:22:27.000-07:00</app:edited>
<title>Sample multivariate experiment</title>
<link rel='alternate' type='text/html'
href='http://www.google.com/websiteoptimizer' />
<link rel='self' type='application/atom+xml'
href='http://www.google.com/analytics/feeds/websiteoptimizer/experiments/48172' />
<gwo:analyticsAccountId>1234</gwo:analyticsAccountId>
<gwo:experimentId>48172</gwo:experimentId>
<gwo:experimentType>Multivariate</gwo:experimentType>
<gwo:numCombinations>12</gwo:numCombinations>
<gwo:numSections>3</gwo:numSections>
<gwo:status>Running</gwo:status>
</entry>
<entry gd:etag='W/"D0cESH47eCp7ImA9WxVQEE0."'>
<id>http://www.google.com/analytics/feeds/websiteoptimizer/experiments/364738</id>
<updated>2009-01-26T13:23:29.000-08:00</updated>
<app:edited>2009-01-26T13:23:29.000-08:00</app:edited>
<title>Sample A/B experiment</title>
<link rel='alternate' type='text/html'
href='http://www.google.com/websiteoptimizer' />
<link rel='self' type='application/atom+xml'
href='http://www.google.com/analytics/feeds/websiteoptimizer/experiments/364738' />
<gwo:analyticsAccountId>1234</gwo:analyticsAccountId>
<gwo:experimentId>364738</gwo:experimentId>
<gwo:experimentType>AB</gwo:experimentType>
<gwo:numAbPageVariations>2</gwo:numAbPageVariations>
<gwo:numCombinations>2</gwo:numCombinations>
<gwo:status>New</gwo:status>
</entry>
</feed>
curl <BASE-OPTIONS> -L "https://www.google.com/analytics/feeds/websiteoptimizer/experiments/{experimentId}/combinations"
For a multivariate experiment with 3 sections and a total of 12 combinations, this command returns the following:
<?xml version='1.0' encoding='utf-8'?>
<feed xmlns='http://www.w3.org/2005/Atom'
xmlns:gwo='http://schemas.google.com/analytics/websiteoptimizer/2009'
xmlns:openSearch='http://a9.com/-/spec/opensearch/1.1/'
xmlns:gd='http://schemas.google.com/g/2005'
gd:etag='W/"DUAARn47eCp7ImA9WxJWFkU."'>
<id>http://www.google.com/analytics/feeds/websiteoptimizer/experiments/48172/combinations/</id>
<updated>2009-06-22T09:22:27.000-07:00</updated>
<title>Combination list for experiment #48172</title>
<link rel='self' type='application/atom+xml'
href='http://www.google.com/analytics/feeds/websiteoptimizer/experiments/48172/combinations/' />
<author>
<name>Google Analytics / Website Optimizer</name>
</author>
<generator version='1.0'>Google Analytics</generator>
<openSearch:totalResults>12</openSearch:totalResults>
<openSearch:startIndex>1</openSearch:startIndex>
<openSearch:itemsPerPage>12</openSearch:itemsPerPage>
<entry gd:etag='W/"DUAARn47eCp7ImA9WxJWFkU."'>
<id>http://www.google.com/analytics/feeds/websiteoptimizer/experiments/48172/combinations/0</id>
<updated>2009-06-22T09:22:27.000-07:00</updated>
<title>Combination #0</title>
<link rel='alternate' type='text/html' href='http://www.google.com/websiteoptimizer' />
<link rel='self' type='application/atom+xml'
href='http://www.google.com/analytics/feeds/websiteoptimizer/experiments/48172/combinations/0' />
<gwo:comboActive>true</gwo:comboActive>
<gwo:comboId>0</gwo:comboId>
<gwo:comboString>0-0-0</gwo:comboString>
</entry>
<entry gd:etag='W/"DUAARn47eCp7ImA9WxJWFkU."'>
<id>http://www.google.com/analytics/feeds/websiteoptimizer/experiments/48172/combinations/1</id>
<updated>2009-06-22T09:22:27.000-07:00</updated>
<title>Combination #1</title>
<link rel='alternate' type='text/html' href='http://www.google.com/websiteoptimizer' />
<link rel='self' type='application/atom+xml'
href='http://www.google.com/analytics/feeds/websiteoptimizer/experiments/48172/combinations/1' />
<gwo:comboActive>true</gwo:comboActive>
<gwo:comboId>1</gwo:comboId>
<gwo:comboString>1-0-0</gwo:comboString>
</entry>
<entry gd:etag='W/"DUAARn47eCp7ImA9WxJWFkU."'>
<id>http://www.google.com/analytics/feeds/websiteoptimizer/experiments/48172/combinations/2</id>
<updated>2009-06-22T09:22:27.000-07:00</updated>
<title>Combination #2</title>
<link rel='alternate' type='text/html' href='http://www.google.com/websiteoptimizer' />
<link rel='self' type='application/atom+xml'
href='http://www.google.com/analytics/feeds/websiteoptimizer/experiments/48172/combinations/2' />
<gwo:comboActive>true</gwo:comboActive>
<gwo:comboId>2</gwo:comboId>
<gwo:comboString>0-1-0</gwo:comboString>
</entry> .... <entry gd:etag='W/"DUAARn47eCp7ImA9WxJWFkU."'>
<id>http://www.google.com/analytics/feeds/websiteoptimizer/experiments/48172/combinations/10</id>
<updated>2009-06-22T09:22:27.000-07:00</updated>
<title>Combination #10</title>
<link rel='alternate' type='text/html' href='http://www.google.com/websiteoptimizer' />
<link rel='self' type='application/atom+xml'
href='http://www.google.com/analytics/feeds/websiteoptimizer/experiments/48172/combinations/10' />
<gwo:comboActive>true</gwo:comboActive>
<gwo:comboId>10</gwo:comboId>
<gwo:comboString>0-2-1</gwo:comboString>
</entry>
<entry gd:etag='W/"DUAARn47eCp7ImA9WxJWFkU."'>
<id>http://www.google.com/analytics/feeds/websiteoptimizer/experiments/48172/combinations/11</id>
<updated>2009-06-22T09:22:27.000-07:00</updated>
<title>Combination #11</title>
<link rel='alternate' type='text/html' href='http://www.google.com/websiteoptimizer' />
<link rel='self' type='application/atom+xml'
href='http://www.google.com/analytics/feeds/websiteoptimizer/experiments/48172/combinations/11' />
<gwo:comboActive>true</gwo:comboActive>
<gwo:comboId>11</gwo:comboId>
<gwo:comboString>1-2-1</gwo:comboString>
</entry>
</feed>
curl <BASE-OPTIONS> -L "https://www.google.com/analytics/feeds/websiteoptimizer/experiments/{experimentId}/combinations/{combinationId}"
For this example (experimentId=48172, combinationId=4), the command
returns the following:
<?xml version='1.0' encoding='utf-8'?>
<entry xmlns='http://www.w3.org/2005/Atom'
xmlns:gwo='http://schemas.google.com/analytics/websiteoptimizer/2009'
xmlns:gd='http://schemas.google.com/g/2005'
gd:etag='W/"DUAARn47eCp7ImA9WxJWFkU."'>
<id>http://www.google.com/analytics/feeds/websiteoptimizer/experiments/48172/combinations/4</id>
<updated>2009-06-22T09:22:27.000-07:00</updated>
<title>Combination #4</title>
<link rel='alternate' type='text/html' href='http://www.google.com/websiteoptimizer' />
<link rel='self' type='application/atom+xml'
href='http://www.google.com/analytics/feeds/websiteoptimizer/experiments/48172/combinations/4' />
<gwo:comboActive>true</gwo:comboActive>
<gwo:comboId>4</gwo:comboId>
<gwo:comboString>0-2-0</gwo:comboString>
</entry>
You can use a combination description instead of the combinationId.
A combination description is a string that contains a list of variation IDs—one
for each section. For example, an experiment with 4 sections might request
a combination using 1-2-0-1 to select the combination corresponding
to variation #1 in section #0, variation #2 in section #1, variation #0 in
section #2 and variation #1 in section #3.
To create a copy of an experiment, create a text file named copyexperiment.xml that
describes your experiment. Set the gwo:analyticsAccountId to
your Analytics account ID (the XXXX number in the UA-XXXX-Y string
from your tracking code) and set the gwo:sourceExperimentId to
the ID of the experiment you want to copy.
<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 experiment copy</title>
<gwo:analyticsAccountId>XXXX</gwo:analyticsAccountId>
<gwo:sourceExperimentId>YYYY</gwo:sourceExperimentId>
</entry>
Then create the experiment copy by sending a POST with this file to the experiments feed:
curl <BASE-OPTIONS> --request POST --data "@copyexperiment.xml" --header "Content-Type:
application/atom+xml" -L "https://www.google.com/analytics/feeds/websiteoptimizer/experiments"
To create/launch a follow-up experiment, create a text file named followupexperiment.xml that
describes your experiment. Set the gwo:analyticsAccountId to
your Analytics account ID (the XXXX number in the UA-XXXX-Y string from
your tracking code) and set the gwo:sourceExperimentId to
the ID of the experiment you want to follow-up.
So far, these are exactly the same steps you follow if you want to make an
experiment copy. A follow-up experiment has one additional piece of required
information: the verification combination ID that is run against the original.
This is specified by setting gwo:verificationCombo to
the desired combination ID.
<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 experiment copy</title>
<gwo:analyticsAccountId>XXXX</gwo:analyticsAccountId>
<gwo:sourceExperimentId>YYYY</gwo:sourceExperimentId>
<gwo:verificationCombo>ZZZZ</gwo:verificationCombo>
</entry>
Then create the follow-up experiment by sending a POST with this file to the experiments feed:
curl <BASE-OPTIONS> --request POST --data "@followupexperiment.xml" --header "Content-Type: application/atom+xml" -L "https://www.google.com/analytics/feeds/websiteoptimizer/experiments"
To delete an experiment, use:
curl <BASE-OPTIONS> --request DELETE -L "https://www.google.com/analytics/feeds/websiteoptimizer/experiments/{experimentId}"
Create a text file named experiment.xml that describes your experiment. Set the gwo:analyticsAccountId to
your Analytics account ID (the XXXX number in the UA-XXXX-Y string
from your tracking code) and set gwo:experimentType to "A/B" as shown:
<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"
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"
curl <BASE-OPTIONS> -L "https://www.google.com/analytics/feeds/websiteoptimizer/experiments/{experimentId}/abpagevariations/{abPageVariationId}"
In this example (e.g.: experimentId=364738, abPageVariationId=1),
this command returns:
<?xml version='1.0' encoding='utf-8'?>
<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'
gd:etag='W/"D0cESH47eCp7ImA9WxVQEE0."'>
<id>http://www.google.com/analytics/feeds/websiteoptimizer/experiments/364738/abpagevariations/1</id>
<updated>2009-01-26T13:23:29.000-08:00</updated>
<app:edited>2009-01-26T13:23:29.000-08:00</app:edited>
<title>Alternate Page</title>
<content>http://www.mywebsite.com/alternatecontent.html</content>
<link rel='alternate' type='text/html' href='http://www.google.com/websiteoptimizer' />
<link rel='self' type='application/atom+xml'
href='http://www.google.com/analytics/feeds/websiteoptimizer/experiments/364738/abpagevariations/1' />
<gwo:abPageVariationId>1</gwo:abPageVariationId>
</entry>
curl <BASE-OPTIONS> -L "https://www.google.com/analytics/feeds/websiteoptimizer/experiments/{experimentId}/abpagevariations"
This command returns:
<?xml version='1.0' encoding='utf-8'?>
<feed 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:openSearch='http://a9.com/-/spec/opensearch/1.1/'
xmlns:gd='http://schemas.google.com/g/2005'
gd:etag='W/"D0cESH47eCp7ImA9WxVQEE0."'>
<id>http://www.google.com/analytics/feeds/websiteoptimizer/experiments/364738/abpagevariations/all</id>
<updated>2009-01-26T13:23:29.000-08:00</updated>
<title>Page variation list for experiment #364738</title>
<link rel='self' type='application/atom+xml'
href='http://www.google.com/analytics/feeds/websiteoptimizer/experiments/364738/abpagevariations/all' />
<author>
<name>Google Analytics / Website Optimizer</name>
</author>
<generator version='1.0'>Google Analytics</generator>
<openSearch:totalResults>2</openSearch:totalResults>
<openSearch:startIndex>1</openSearch:startIndex>
<openSearch:itemsPerPage>2</openSearch:itemsPerPage>
<entry gd:etag='W/"D0cESH47eCp7ImA9WxVQEE0."'>
<id>http://www.google.com/analytics/feeds/websiteoptimizer/experiments/364738/abpagevariations/0</id>
<updated>2009-01-26T13:23:29.000-08:00</updated>
<app:edited>2009-01-26T13:23:29.000-08:00</app:edited>
<title>Original</title>
<content>http://www.mywebsite.com/originalcontent.html</content>
<link rel='alternate' type='text/html' href='http://www.google.com/websiteoptimizer' />
<link rel='self' type='application/atom+xml'
href='http://www.google.com/analytics/feeds/websiteoptimizer/experiments/364738/abpagevariations/0' />
<gwo:abPageVariationId>0</gwo:abPageVariationId>
</entry>
<entry gd:etag='W/"D0cESH47eCp7ImA9WxVQEE0."'>
<id>http://www.google.com/analytics/feeds/websiteoptimizer/experiments/364738/abpagevariations/1</id>
<updated>2009-01-26T13:23:29.000-08:00</updated>
<app:edited>2009-01-26T13:23:29.000-08:00</app:edited>
<title>Alternate Page</title>
<content>http://www.mywebsite.com/alternatecontent.html</content>
<link rel='alternate' type='text/html' href='http://www.google.com/websiteoptimizer' />
<link rel='self' type='application/atom+xml'
href='http://www.google.com/analytics/feeds/websiteoptimizer/experiments/364738/abpagevariations/1' />
<gwo:abPageVariationId>1</gwo:abPageVariationId>
</entry>
</feed>
Create a text file named updatepagevariation.xml that contains the changes you want to make to the 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>New page variation name</title>
<content>http://www.website.com/newpagevariation.html</content>
</entry>
Then update the page variation by sending a PUT with this file to the abpagevariations feed:
curl <BASE-OPTIONS> --request PUT --data "@pagevariation.xml" --header "Content-Type: application/atom+xml" -L "https://www.google.com/analytics/feeds/websiteoptimizer/experiments/{experimentId}/abpagevariations/{abPageVariationId}"
To delete a page variation, use:
curl <BASE-OPTIONS> --request DELETE -L "https://www.google.com/analytics/feeds/websiteoptimizer/experiments/{experimentId}/abpagevariations/{abPageVariationId}"
Create a text file named experiment.xml that describes your experiment.
Set the gwo:analyticsAccountId to
your Analytics account ID (the XXXX number in the UA-XXXX-Y string
from your tracking code) and set the gwo:experimentType to Multivariate as shown:
<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 experiment</title>
<gwo:analyticsAccountId>XXXX</gwo:analyticsAccountId>
<gwo:experimentType>Multivariate</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"
Create a text file named section.xml that describes your new multivariate section. All that is needed is the section name:
<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>Section name</title>
</entry>
Then add this section by sending a POST with this file to the experiment API sections feed:
curl <BASE-OPTIONS> --request POST --data "@section.xml" --header "Content-Type: application/atom+xml" -L "https://www.google.com/analytics/feeds/websiteoptimizer/experiments/{experimentId}/sections"
curl <BASE-OPTIONS> -L "https://www.google.com/analytics/feeds/websiteoptimizer/experiments/{experimentId}/sections/{sectionId}"
In this example (e.g. experimentId=48172, sectionId=0), this
command returns:
<?xml version='1.0' encoding='utf-8'?>
<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'
gd:etag='W/"DUAARn47eCp7ImA9WxJWFkU."'>
<id>http://www.google.com/analytics/feeds/websiteoptimizer/experiments/48172/sections/0</id>
<updated>2009-06-22T09:22:27.000-07:00</updated>
<app:edited>2009-06-22T09:22:27.000-07:00</app:edited>
<title>Section1</title>
<link rel='alternate' type='text/html'
href='http://www.google.com/websiteoptimizer' />
<link rel='self' type='application/atom+xml'
href='http://www.google.com/analytics/feeds/websiteoptimizer/experiments/48172/sections/0' />
<gwo:numVariations>2</gwo:numVariations>
<gwo:sectionBeginScript><script>utmx_section("Section1")</script></gwo:sectionBeginScript>
<gwo:sectionEndScript></noscript></gwo:sectionEndScript>
</entry>
curl <BASE-OPTIONS> -L "https://www.google.com/analytics/feeds/websiteoptimizer/experiments/{experimentId}/sections"
This command returns the following:
<?xml version='1.0' encoding='utf-8'?>
<feed 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:openSearch='http://a9.com/-/spec/opensearch/1.1/'
xmlns:gd='http://schemas.google.com/g/2005'
gd:etag='W/"DUAARn47eCp7ImA9WxJWFkU."'>
<id>http://www.google.com/analytics/feeds/websiteoptimizer/experiments/48172/sections/</id>
<updated>2009-06-22T09:22:27.000-07:00</updated>
<title>Section list for experiment #48172</title>
<link rel='self' type='application/atom+xml'
href='http://www.google.com/analytics/feeds/websiteoptimizer/experiments/48172/sections/' />
<author>
<name>Google Analytics / Website Optimizer</name>
</author>
<generator version='1.0'>Google Analytics</generator>
<openSearch:totalResults>3</openSearch:totalResults>
<openSearch:startIndex>1</openSearch:startIndex>
<openSearch:itemsPerPage>3</openSearch:itemsPerPage>
<entry gd:etag='W/"DUAARn47eCp7ImA9WxJWFkU."'>
<id>http://www.google.com/analytics/feeds/websiteoptimizer/experiments/48172/sections/0</id>
<updated>2009-06-22T09:22:27.000-07:00</updated>
<app:edited>2009-06-22T09:22:27.000-07:00</app:edited>
<title>Section1</title>
<link rel='alternate' type='text/html' href='http://www.google.com/websiteoptimizer' />
<link rel='self' type='application/atom+xml'
href='http://www.google.com/analytics/feeds/websiteoptimizer/experiments/48172/sections/0' />
<gwo:numVariations>2</gwo:numVariations>
</entry>
<entry gd:etag='W/"DUAARn47eCp7ImA9WxJWFkU."'>
<id>http://www.google.com/analytics/feeds/websiteoptimizer/experiments/48172/sections/1</id>
<updated>2009-06-22T09:22:27.000-07:00</updated>
<app:edited>2009-06-22T09:22:27.000-07:00</app:edited>
<title>Section2</title>
<link rel='alternate' type='text/html' href='http://www.google.com/websiteoptimizer' />
<link rel='self' type='application/atom+xml'
href='http://www.google.com/analytics/feeds/websiteoptimizer/experiments/48172/sections/1' />
<gwo:numVariations>3</gwo:numVariations>
</entry>
<entry gd:etag='W/"DUAARn47eCp7ImA9WxJWFkU."'>
<id>http://www.google.com/analytics/feeds/websiteoptimizer/experiments/48172/sections/2</id>
<updated>2009-06-22T09:22:27.000-07:00</updated>
<app:edited>2009-06-22T09:22:27.000-07:00</app:edited>
<title>Section3</title>
<link rel='alternate' type='text/html' href='http://www.google.com/websiteoptimizer' />
<link rel='self' type='application/atom+xml'
href='http://www.google.com/analytics/feeds/websiteoptimizer/experiments/48172/sections/2' />
<gwo:numVariations>2</gwo:numVariations>
</entry>
</feed>
Create a text file named updatesection.xml that describes the
updates to the multivariate section:
<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>New section name</title>
</entry>
Then update the section by sending a PUT with this file to the sections feed:
curl <BASE-OPTIONS> --request PUT --data "@updatesection.xml" --header "Content-Type: application/atom+xml" -L "https://www.google.com/analytics/feeds/websiteoptimizer/experiments/{experimentId}/sections/{sectionId}"
To delete a section, use:
curl <BASE-OPTIONS> --request DELETE -L "https://www.google.com/analytics/feeds/websiteoptimizer/experiments/{experimentId}/sections/{sectionId}"
Create a text file named variation.xml that describes your new
section 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>Variation name</title>
<content>variation content</content>
</entry>
Then add this variation by sending a POST with this file to the experiment section's variations feed:
curl <BASE-OPTIONS> --request POST --data "@variation.xml" --header "Content-Type: application/atom+xml" -L "https://www.google.com/analytics/feeds/websiteoptimizer/experiments/{experimentId}/sections/{sectionId}/variations"
curl <BASE-OPTIONS > -L "https://www.google.com/analytics/feeds/websiteoptimizer/experiments/{experimentId}/sections/{sectionId}/variations/{variationId}
In this example (e.g. experimentId=48172, sectionId=0, variationId=1),
this command returns:
<?xml version='1.0' encoding='utf-8'?>
<entry xmlns='http://www.w3.org/2005/Atom'
xmlns:app='http://www.w3.org/2007/app'
xmlns:gd='http://schemas.google.com/g/2005'
gd:etag='W/"DUAARn47eCp7ImA9WxJWFkU."'>
<id>http://www.google.com/analytics/feeds/websiteoptimizer/experiments/48172/sections/0/variations/1</id>
<updated>2009-06-22T09:22:27.000-07:00</updated>
<app:edited>2009-06-22T09:22:27.000-07:00</app:edited>
<title>Section1 - variation</title>
<content>Section1 - variation content</content>
<link rel='alternate' type='text/html'
href='http://www.google.com/websiteoptimizer' />
<link rel='self' type='application/atom+xml'
href='http://www.google.com/analytics/feeds/websiteoptimizer/experiments/48172/sections/0/variations/1' />
</entry>
curl <BASE-OPTIONS> -L "https://www.google.com/analytics/feeds/websiteoptimizer/experiments/{experimentId}/sections/{sectionId}/variations"
In this example (e.g. experimentId=48172, sectionId=0), this
command returns:
<?xml version='1.0' encoding='utf-8'?>
<feed xmlns='http://www.w3.org/2005/Atom'
xmlns:app='http://www.w3.org/2007/app'
xmlns:openSearch='http://a9.com/-/spec/opensearch/1.1/'
xmlns:gd='http://schemas.google.com/g/2005'
gd:etag='W/"DUAARn47eCp7ImA9WxJWFkU."'>
<id>http://www.google.com/analytics/feeds/websiteoptimizer/experiments/48172/sections/0/variations/all</id>
<updated>2009-06-22T09:22:27.000-07:00</updated>
<title>Variation list for section #0 of experiment #48172</title>
<link rel='self' type='application/atom+xml'
href='http://www.google.com/analytics/feeds/websiteoptimizer/experiments/48172/sections/0/variations/all' />
<author>
<name>Google Analytics / Website Optimizer</name>
</author>
<generator version='1.0'>Google Analytics</generator>
<openSearch:totalResults>2</openSearch:totalResults>
<openSearch:startIndex>1</openSearch:startIndex>
<openSearch:itemsPerPage>2</openSearch:itemsPerPage>
<entry gd:etag='W/"DUAARn47eCp7ImA9WxJWFkU."'>
<id>http://www.google.com/analytics/feeds/websiteoptimizer/experiments/48172/sections/0/variations/0</id>
<updated>2009-06-22T09:22:27.000-07:00</updated>
<app:edited>2009-06-22T09:22:27.000-07:00</app:edited>
<title>Section1 - Original</title>
<content>Section1 - original content</content>
<link rel='alternate' type='text/html'
href='http://www.google.com/websiteoptimizer' />
<link rel='self' type='application/atom+xml'
href='http://www.google.com/analytics/feeds/websiteoptimizer/experiments/48172/sections/0/variations/0' />
</entry>
<entry gd:etag='W/"DUAARn47eCp7ImA9WxJWFkU."'>
<id>http://www.google.com/analytics/feeds/websiteoptimizer/experiments/48172/sections/0/variations/1</id>
<updated>2009-06-22T09:22:27.000-07:00</updated>
<app:edited>2009-06-22T09:22:27.000-07:00</app:edited>
<title>Section1 - variation</title>
<content>Section1 - variation content</content>
<link rel='alternate' type='text/html'
href='http://www.google.com/websiteoptimizer' />
<link rel='self' type='application/atom+xml'
href='http://www.google.com/analytics/feeds/websiteoptimizer/experiments/48172/sections/0/variations/1' />
</entry>
</feed>
Create a text file named updatevariation.xml that describes the changes to the section 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>New variation name</title>
<content>new variation content</content>
</entry>
Then update the variation by sending a PUT with this file to the variations feed:
curl <BASE-OPTIONS> --request PUT --data "@updatevariation.xml" --header "Content-Type: application/atom+xml" -L "https://www.google.com/analytics/feeds/websiteoptimizer/experiments/{experimentId}/sections/{sectionId}/variations/{variationId}"
To delete the variation, use:
curl <BASE-OPTIONS> --request DELETE -L "https://www.google.com/analytics/feeds/websiteoptimizer/experiments/{experimentId}/sections/{sectionId}/variations/{variationId}"
The delete will fail if the gd:etag in your delete request does not match the current etag on the server.