ต้องมีการให้สิทธิ์
อัปเดตการทดสอบที่มีอยู่ ดูตัวอย่าง
นอกเหนือจากพารามิเตอร์มาตรฐานแล้ว เมธอดนี้ยังรองรับพารามิเตอร์ที่แสดงในตารางพารามิเตอร์ด้วย
ส่งคำขอ
คำขอ HTTP
PUT https://www.googleapis.com/analytics/v3/management/accounts/accountId/webproperties/webPropertyId/profiles/profileId/experiments/experimentId
พารามิเตอร์
ชื่อพารามิเตอร์ | ค่า | คำอธิบาย |
---|---|---|
พารามิเตอร์เส้นทาง | ||
accountId |
string |
รหัสบัญชีของการทดสอบที่จะอัปเดต |
experimentId |
string |
รหัสการทดสอบของการทดสอบที่จะอัปเดต |
profileId |
string |
ดูรหัส (โปรไฟล์) ของการทดสอบที่จะอัปเดต |
webPropertyId |
string |
รหัสเว็บพร็อพเพอร์ตี้ของการทดสอบที่จะอัปเดต |
การให้สิทธิ์
คำขอนี้ต้องได้รับสิทธิ์อย่างน้อย 1 ขอบเขตต่อไปนี้ (อ่านเพิ่มเติมเกี่ยวกับการตรวจสอบสิทธิ์และการให้สิทธิ์)
ขอบเขต |
---|
https://www.googleapis.com/auth/analytics |
https://www.googleapis.com/auth/analytics.edit |
เนื้อหาของคำขอ
ในเนื้อหาคำขอ ให้ระบุทรัพยากรmanagement.การทดลองใช้ฟรีพร้อมพร็อพเพอร์ตี้ต่อไปนี้
ชื่อพร็อพเพอร์ตี้ | ค่า | คำอธิบาย | Notes |
---|---|---|---|
พร็อพเพอร์ตี้ที่จำเป็น | |||
id |
string |
รหัสการทดสอบ จำเป็นสำหรับแพตช์และการอัปเดต ไม่อนุญาตให้สร้าง | |
name |
string |
ชื่อการทดสอบ ไม่สามารถเปลี่ยนแปลงฟิลด์นี้ได้สำหรับการทดสอบที่มีสถานะ "ENDED" คุณต้องระบุข้อมูลในช่องนี้เมื่อสร้างการทดสอบ | เขียนได้ |
status |
string |
สถานะการทดสอบ ค่าที่เป็นไปได้ ได้แก่ "DRAFT", "READY_TO_RUN", "RUNNING", "ENDED" คุณสามารถสร้างการทดสอบได้ในสถานะ "DRAFT", "READY_TO_RUN" หรือ "RUNNING" คุณต้องระบุข้อมูลในช่องนี้เมื่อสร้างการทดสอบ | เขียนได้ |
variations[].name |
string |
ชื่อของรูปแบบ คุณต้องระบุข้อมูลในช่องนี้เมื่อสร้างการทดสอบ ไม่สามารถเปลี่ยนแปลงฟิลด์นี้ได้สำหรับการทดสอบที่มีสถานะ "ENDED" | เขียนได้ |
พร็อพเพอร์ตี้ที่ไม่บังคับ | |||
description |
string |
หมายเหตุเกี่ยวกับการทดสอบนี้ | เขียนได้ |
editableInGaUi |
boolean |
หากเป็นจริง ผู้ใช้ปลายทางจะแก้ไขการทดสอบผ่านทางอินเทอร์เฟซผู้ใช้ Google Analytics ได้ | เขียนได้ |
equalWeighting |
boolean |
บูลีนระบุว่าจะกระจายการเข้าชมในทุกรูปแบบอย่างเท่าเทียมกันหรือไม่ หากค่าเป็น "เท็จ" การทดสอบเนื้อหาจะใช้ลักษณะการทำงานเริ่มต้นของการปรับการเข้าชมแบบไดนามิกตามประสิทธิภาพของรูปแบบต่างๆ ไม่บังคับ -- ค่าเริ่มต้นคือ "เท็จ" ไม่สามารถเปลี่ยนแปลงฟิลด์นี้ได้สำหรับการทดสอบที่มีสถานะ "ENDED" | เขียนได้ |
minimumExperimentLengthInDays |
integer |
จำนวนเต็มใน [3, 90] ระบุระยะเวลาขั้นต่ำของการทดสอบ เปลี่ยนแปลงสำหรับการทดสอบที่ทำงานอยู่ได้ ไม่สามารถเปลี่ยนแปลงฟิลด์นี้ได้สำหรับการทดสอบที่มีสถานะ "ENDED" | เขียนได้ |
objectiveMetric |
string |
เมตริกที่การทดสอบกำลังเพิ่มประสิทธิภาพ ค่าที่ถูกต้อง: "ga:goal(n)Completions", "ga:adsenseAdsClicks", "ga:adsenseAdsViewed", "ga:adsenseRevenue", "ga:bounces", "ga:pageviews", "ga:sessionDuration", "ga:transactions", "ga:transactionRevenue" ต้องกรอกช่องนี้หากสถานะคือ "RUNNING" และ กำลังแสดงFramework เป็น "REDIRECT" หรือ "API" | เขียนได้ |
optimizationType |
string |
ควรย่อหรือขยายวัตถุประสงค์เมตริกสูงสุดหรือไม่ ค่าที่เป็นไปได้คือ "MAXIMUM", "MINIMUM" ไม่บังคับ -- ค่าเริ่มต้นคือ "MAXIMUM" ระบุไม่ได้หากไม่มี objectMetric. แก้ไขไม่ได้เมื่อสถานะเป็น "กำลังทำงาน" หรือ "ENDED" | เขียนได้ |
rewriteVariationUrlsAsOriginal |
boolean |
บูลีนที่ระบุว่าจะมีการเขียน URL รูปแบบใหม่เพื่อให้ตรงกับ URL ดั้งเดิมหรือไม่ ไม่สามารถเปลี่ยนแปลงฟิลด์นี้ได้สำหรับการทดสอบที่มีสถานะ "ENDED" | เขียนได้ |
servingFramework |
string |
เฟรมเวิร์กที่ใช้เพื่อแสดงรูปแบบการทดสอบต่างๆ และประเมินผลลัพธ์ หนึ่งใน:
|
เขียนได้ |
trafficCoverage |
double |
จำนวนจุดลอยตัวระหว่าง 0 ถึง 1 ระบุเศษส่วนของการเข้าชมที่เข้าร่วมในการทดสอบ เปลี่ยนแปลงสำหรับการทดสอบที่ทำงานอยู่ได้ ไม่สามารถเปลี่ยนแปลงฟิลด์นี้ได้สำหรับการทดสอบที่มีสถานะ "ENDED" | เขียนได้ |
variations[] |
list |
อาร์เรย์ของรูปแบบ รูปแบบแรกในอาร์เรย์คือรูปแบบเดิม จำนวนรูปแบบอาจไม่เปลี่ยนแปลงเมื่อการทดสอบอยู่ในสถานะทำงานอยู่ ต้องมีอย่างน้อย 2 รูปแบบก่อนที่จะตั้งค่าสถานะเป็น "ทำงาน" ได้ | เขียนได้ |
variations[].status |
string |
สถานะของรูปแบบ ค่าที่เป็นไปได้ ได้แก่ "ACTIVE", "INACTIVE" รูปแบบที่ไม่มีการใช้งานจะไม่แสดง ไม่สามารถเปลี่ยนแปลงฟิลด์นี้ได้สำหรับการทดสอบที่มีสถานะ "ENDED" | เขียนได้ |
variations[].url |
string |
URL ของรูปแบบ ไม่สามารถเปลี่ยนแปลงฟิลด์นี้ได้สำหรับการทดสอบที่มีสถานะ "กำลังทำงาน" หรือ "ENDED" | เขียนได้ |
winnerConfidenceLevel |
double |
จำนวนจุดลอยตัวระหว่าง 0 ถึง 1 ระบุระดับความเชื่อมั่นที่จำเป็นในการเลือกผู้ชนะ ไม่สามารถเปลี่ยนแปลงฟิลด์นี้ได้สำหรับการทดสอบที่มีสถานะ "ENDED" | เขียนได้ |
คำตอบ
หากสำเร็จ เมธอดนี้จะแสดงผลทรัพยากรmanagement.experiment ในเนื้อหาการตอบสนอง
ตัวอย่าง
หมายเหตุ: ตัวอย่างโค้ดที่มีสำหรับวิธีการนี้ไม่ได้แสดงถึงภาษาโปรแกรมที่รองรับทั้งหมด (ดูรายการภาษาที่รองรับได้ในหน้าไลบรารีของไคลเอ็นต์)
Java
/* * Note: This code assumes you have an authorized Analytics service object. * See the Experiments Developer Guide for details. */ // This example updates an existing experiment with new variations. Variations variationA = new Variations(); variationA.setName("Home Alpha"); variationA.setUrl("homeA.html"); Variations variationB = new Variations(); variationB.setName("Home Beta"); variationB.setUrl("homeB.html"); List<Variations> variations = Arrays.asList(variationA, variationB); try { // First get an existing Experiment. Experiment body = analytics.management().experiments().get("123456", "UA-123456-1", "7654321", "122333444455555").execute(); // Set the new variations. body.setVariations(variations); // Call Update with the updated experiment. analytics.management().experiments().update("123456", "UA-123456-1", "7654321", "122333444455555", body).execute(); } catch (GoogleJsonResponseException e) { System.err.println("There was a service error: " + e.getDetails().getCode() + " : " + e.getDetails().getMessage()); }
PHP
/** * Note: This code assumes you have an authorized Analytics service object. * See the Experiments Developer Guide for details. */ /** * This request updates an existing experiment. */ // Construct the first variation. $variationA = new Google_Service_Analytics_ExperimentVariations(); $variationA->setName('VariationA'); $variationA->setUrl('index.html'); // Construct the second variation. $variationB = new Google_Service_Analytics_ExperimentVariations(); $variationB->setName('VariationB'); $variationB->setUrl('indexB.html'); try { // Get an existing Experiment. $experiment = $analytics->management_experiments->get('123456', 'UA-123456-1', '7654321', '122333444455555'); // Set the new variations. $experiment->setVariations(array($variationA, $variationB)); // Call the update method with the updated experiment. $analytics->management_experiments->update('123456', 'UA-123456-1', '7654321', '122333444455555', $experiment); } catch (apiServiceException $e) { print 'There was an Analytics API service error ' . $e->getCode() . ':' . $e->getMessage(); } catch (apiException $e) { print 'There was a general API error ' . $e->getCode() . ':' . $e->getMessage(); }
Python
# Note: This code assumes you have an authorized Analytics service object. # See the Experiments Developer Guide for details. # This request updates an existing experiment with a new name, # and new variations. try: analytics.management().experiments().update( accountId='123456', webPropertyId='UA-123456-1', profileId='7654321', experimentId='ABCDEFG123456abcdefg', body={ 'name': 'Updated Test Title', 'status': 'DRAFT', 'variations': [ { 'name': 'Checkout Page', 'url': 'checkout.html' }, { 'name': 'Proposed Checkout Page', 'url': 'newCheckout.html' } ] } ).execute() except TypeError, error: # Handle errors in constructing a query. print 'There was an error in constructing your query : %s' % error except HttpError, error: # Handle API errors. print ('There was an API error : %s : %s' % (error.resp.status, error.resp.reason))
JavaScript
ใช้ไลบรารีของไคลเอ็นต์ JavaScript
/* * Note: This code assumes you have an authorized Analytics client object. * See the Experiments Developer Guide for details. */ /* * This request updates an existing experiment. */ function updateExperiment() { var request = gapi.client.analytics.management.experiments.update( { 'accountId': '123456', 'webPropertyId': 'UA-123456-1', 'profileId': '7654321', 'experimentId': '122333444455555', 'resource': { 'name': 'Landing Page Test', 'status': 'DRAFT', 'variations': [ { 'name': 'VariationA', 'url': 'index.html' }, { 'name': 'VariationB', 'url': 'indexB.html' } ] } }); request.execute(function (response) { // Handle the response. }); }