Dealing with Optimizer(I)curl

本文介绍如何利用cURL工具进行Google Analytics网站优化器的实验管理,包括获取认证令牌、请求实验状态、更新实验状态及创建A/B测试实验等操作。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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=4myhappylife@gmail.com \
-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
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值