ต้องมีการให้สิทธิ์
แสดงรายการมิติข้อมูลที่กําหนดเองซึ่งผู้ใช้มีสิทธิ์เข้าถึง ลองใช้เลยหรือดูตัวอย่าง
ส่งคำขอ
คำขอ HTTP
GET https://www.googleapis.com/analytics/v3/management/accounts/accountId/webproperties/webPropertyId/customDimensions
พารามิเตอร์
ชื่อพารามิเตอร์ | ค่า | คำอธิบาย |
---|---|---|
พารามิเตอร์เส้นทาง | ||
accountId |
string |
รหัสบัญชีสําหรับมิติข้อมูลที่กําหนดเองเพื่อดึงข้อมูล |
webPropertyId |
string |
รหัสเว็บพร็อพเพอร์ตี้สําหรับมิติข้อมูลที่กําหนดเองเพื่อดึงข้อมูล |
พารามิเตอร์การค้นหาที่ไม่บังคับ | ||
max-results |
integer |
จำนวนสูงสุดของมิติข้อมูลที่กำหนดเองที่จะรวมในคำตอบนี้ |
start-index |
integer |
ดัชนีของเอนทิตีแรกที่จะดึงข้อมูล ใช้พารามิเตอร์นี้เป็นกลไกการใส่เลขหน้าร่วมกับพารามิเตอร์ max-results |
การให้สิทธิ์
คำขอนี้ต้องได้รับการให้สิทธิ์อย่างน้อย 1 ขอบเขตต่อไปนี้ (อ่านเพิ่มเติมเกี่ยวกับการตรวจสอบสิทธิ์และการให้สิทธิ์)
ขอบเขต |
---|
https://www.googleapis.com/auth/analytics.readonly |
https://www.googleapis.com/auth/analytics |
เนื้อหาของคำขอ
อย่าแสดงเนื้อหาของคำขอด้วยวิธีนี้
คำตอบ
หากทำสำเร็จ เมธอดนี้จะแสดงเนื้อหาการตอบสนองที่มีโครงสร้างต่อไปนี้
{ "kind": "analytics#customDimensions", "username": string, "totalResults": integer, "startIndex": integer, "itemsPerPage": integer, "previousLink": string, "nextLink": string, "items": [ management.customDimensions Resource ] }
ชื่อพร็อพเพอร์ตี้ | ค่า | คำอธิบาย | Notes |
---|---|---|---|
kind |
string |
ประเภทคอลเล็กชัน | |
username |
string |
รหัสอีเมลของผู้ใช้ที่ตรวจสอบสิทธิ์แล้ว | |
totalResults |
integer |
จำนวนผลลัพธ์ทั้งหมดสำหรับข้อความค้นหา โดยไม่คำนึงถึงจำนวนผลลัพธ์ในการตอบกลับ | |
startIndex |
integer |
ดัชนีเริ่มต้นของทรัพยากร ซึ่งเท่ากับ 1 โดยค่าเริ่มต้น หรือระบุโดยพารามิเตอร์การค้นหา Start-index | |
itemsPerPage |
integer |
จำนวนทรัพยากรสูงสุดที่การตอบกลับมีได้ โดยไม่คำนึงถึงจำนวนทรัพยากรที่แสดงผลจริง ค่าอยู่ในช่วง 1 ถึง 1000 โดยมีค่า 1000 โดยค่าเริ่มต้น หรือมีการระบุโดยพารามิเตอร์การค้นหาผลลัพธ์สูงสุด | |
previousLink |
string |
ลิงก์ไปยังหน้าก่อนหน้าสำหรับคอลเล็กชันมิติข้อมูลที่กำหนดเองนี้ | |
nextLink |
string |
ลิงก์ไปยังหน้าถัดไปของคอลเล็กชันมิติข้อมูลที่กําหนดเองนี้ | |
items[] |
list |
คอลเล็กชันของมิติข้อมูลที่กําหนดเอง |
ตัวอย่าง
หมายเหตุ: ตัวอย่างโค้ดที่มีสำหรับวิธีการนี้ไม่ได้แสดงถึงภาษาโปรแกรมที่รองรับทั้งหมด (ดูรายการภาษาที่รองรับได้ในหน้าไลบรารีของไคลเอ็นต์)
Java
/** * Note: This code assumes you have an authorized Analytics service object. */ /** * This request lists all custom dimensions for the authorized user. */ try { CustomDimensions dimensions = analytics.management.customDimensions .list("12345", "UA-12345-1").execute(); } catch (GoogleJsonResponseException e) { System.err.println("There was a service error: " + e.getDetails().getCode() + " : " + e.getDetails().getMessage()); } /** * The results of the list method are stored in the dimensions object. * The following code shows how to iterate through them. */ for (CustomDimension dimension : dimensions.getItems()) { System.out.println("Dimension Kind: " + dimension.getKind()); System.out.println("Dimension Id: " + dimension.getId()); System.out.println("Account ID: " + dimension.getAccountId()); System.out.println("Property ID: " + dimension.getWebPropertyId()); System.out.println("Dimension Name: " + dimension.getName()); System.out.println("Dimension Index: " + dimension.getIndex()); System.out.println("Dimension Scope: " + dimension.getScope()); System.out.println("Dimension Active: " + dimension.getActive()); System.out.println("Dimension Created: " + dimension.getCreated()); System.out.println("Dimension Updated: " + dimension.getUpdated()); }
Python
# Note: This code assumes you have an authorized Analytics service object. # This request lists all custom dimensions for the authorized user. try: dimensions = analytics.management().customDimensions().list( accountId='123456', webPropertyId='UA-123456-1', ).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)) # The results of the list method are stored in the dimensions object. # The following code shows how to iterate through them. for dimension in dimensions.get('items', []): print 'Dimension Kind = %s' % dimension.get('kind') print 'Dimension Id = %s' % dimension.get('id') print 'Account ID = %s' % dimension.get('accountId') print 'Property ID = %s' % dimension.get('webPropertyId') print 'Dimension Name = %s' % dimension.get('name') print 'Dimension Index = %s' % dimension.get('index') print 'Dimension Scope = %s' % dimension.get('scope') print 'Dimension Active = %s' % dimension.get('active') print 'Dimension Created = %s' % dimension.get('created') print 'Dimension Updated = %s' % dimension.get('updated')
ลองใช้เลย
ใช้ API Explorer ด้านล่างเพื่อเรียกใช้เมธอดนี้ในข้อมูลสดและดูการตอบสนอง หรือลองใช้เครื่องมือสำรวจแบบสแตนด์อโลน