ต้องมีการให้สิทธิ์
อัปเดตมิติข้อมูลที่กําหนดเองที่มีอยู่ ลองใช้เลยหรือดูตัวอย่าง
ส่งคำขอ
คำขอ HTTP
PUT https://www.googleapis.com/analytics/v3/management/accounts/accountId/webproperties/webPropertyId/customDimensions/customDimensionId
พารามิเตอร์
ชื่อพารามิเตอร์ | ค่า | คำอธิบาย |
---|---|---|
พารามิเตอร์เส้นทาง | ||
accountId |
string |
รหัสบัญชีสําหรับมิติข้อมูลที่กําหนดเองที่ต้องการอัปเดต |
customDimensionId |
string |
รหัสมิติข้อมูลที่กําหนดเองสําหรับมิติข้อมูลที่กําหนดเองที่จะอัปเดต |
webPropertyId |
string |
รหัสเว็บพร็อพเพอร์ตี้สําหรับมิติข้อมูลที่กําหนดเองที่จะอัปเดต |
พารามิเตอร์การค้นหาที่ไม่บังคับ | ||
ignoreCustomDataSourceLinks |
boolean |
บังคับการอัปเดตและไม่สนใจคำเตือนที่เกี่ยวข้องกับมิติข้อมูลที่กำหนดเองซึ่งลิงก์กับแหล่งข้อมูล / ชุดข้อมูลที่กำหนดเอง
(ค่าเริ่มต้น: false )
|
การให้สิทธิ์
คำขอนี้ต้องได้รับการให้สิทธิ์ตามขอบเขตต่อไปนี้ (อ่านเพิ่มเติมเกี่ยวกับการตรวจสอบสิทธิ์และการให้สิทธิ์)
ขอบเขต |
---|
https://www.googleapis.com/auth/analytics.edit |
เนื้อหาของคำขอ
ในเนื้อหาคำขอ ให้ระบุทรัพยากรmanagement.customDimension
คำตอบ
หากทำสำเร็จ เมธอดนี้จะแสดงผลทรัพยากรmanagement.customDimension ในเนื้อหาการตอบกลับ
ตัวอย่าง
หมายเหตุ: ตัวอย่างโค้ดที่มีสำหรับวิธีการนี้ไม่ได้แสดงถึงภาษาโปรแกรมที่รองรับทั้งหมด (ดูรายการภาษาที่รองรับได้ในหน้าไลบรารีของไคลเอ็นต์)
Java
/* * Note: This code assumes you have an authorized Analytics service object. */ /* * This request updates an existing custom dimension. */ // Construct the body of the request and set its properties. CustomDimension body = new CustomDimension(); body.setName("Campaign Group"); body.setScope("SESSION"); body.setActive(true); try { analytics.management().customDimensions() .update("123456", "UA-123456-1", "ga:dimension2", body).execute(); } catch (GoogleJsonResponseException e) { System.err.println("There was a service error: " + e.getDetails().getCode() + " : " + e.getDetails().getMessage()); }
Python
# Note: This code assumes you have an authorized Analytics service object. # This request updates an existing custom dimension. try: analytics.management().customDimensions().update( accountId='123456', webPropertyId='UA-123456-1', customDimensionId='ga:dimension2', body={ 'name': 'Campaign Group', 'scope': 'SESSION', 'active': True } ).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))
ลองใช้เลย
ใช้ API Explorer ด้านล่างเพื่อเรียกใช้เมธอดนี้ในข้อมูลสดและดูการตอบสนอง หรือลองใช้เครื่องมือสำรวจแบบสแตนด์อโลน