ลองใช้เซิร์ฟเวอร์ MCP สำหรับ Google Analytics ติดตั้งจาก
GitHub และดูรายละเอียดเพิ่มเติมได้ที่
ประกาศ
OrderBy
จัดทุกอย่างให้เป็นระเบียบอยู่เสมอด้วยคอลเล็กชัน
บันทึกและจัดหมวดหมู่เนื้อหาตามค่ากำหนดของคุณ
"จัดเรียงตาม" จะกําหนดวิธีจัดเรียงแถวในการตอบกลับ เช่น การจัดเรียงแถวตามจํานวนเหตุการณ์จากมากไปน้อยเป็นการจัดเรียงรูปแบบหนึ่ง และการจัดเรียงแถวตามสตริงชื่อเหตุการณ์เป็นการจัดเรียงรูปแบบอื่น
การแสดง JSON |
{
"desc": boolean,
// Union field one_order_by can be only one of the following:
"metric": {
object (MetricOrderBy )
},
"dimension": {
object (DimensionOrderBy )
},
"pivot": {
object (PivotOrderBy )
}
// End of list of possible types for union field one_order_by .
} |
ช่อง |
desc |
boolean
หากเป็น "จริง" ระบบจะจัดเรียงจากมากไปน้อย
|
ฟิลด์สหภาพ one_order_by ระบุประเภทลําดับตาม 1 ประเภทสําหรับ OrderBy one_order_by ต้องเป็นค่าใดค่าหนึ่งต่อไปนี้เท่านั้น |
metric |
object (MetricOrderBy )
จัดเรียงผลลัพธ์ตามค่าของเมตริก
|
dimension |
object (DimensionOrderBy )
จัดเรียงผลลัพธ์ตามค่าของมิติข้อมูล
|
pivot |
object (PivotOrderBy )
จัดเรียงผลลัพธ์ตามค่าของเมตริกภายในกลุ่มคอลัมน์ Pivot
|
MetricOrderBy
การแสดง JSON |
{
"metricName": string
} |
ช่อง |
metricName |
string
ชื่อเมตริกในคําขอเพื่อจัดเรียง
|
DimensionOrderBy
การแสดง JSON |
{
"dimensionName": string,
"orderType": enum (OrderType )
} |
ช่อง |
dimensionName |
string
ชื่อมิติข้อมูลในคําขอที่จะจัดเรียงตาม
|
orderType |
enum (OrderType )
ควบคุมกฎสําหรับลําดับค่าของมิติข้อมูล
|
OrderType
กฎในการจัดลําดับค่ามิติข้อมูลสตริง
Enum |
ORDER_TYPE_UNSPECIFIED |
ไม่ระบุ |
ALPHANUMERIC |
จัดเรียงตัวอักษรและตัวเลขคละกันตาม Code Point ของ Unicode เช่น "2" < "A" < "X" < "b" < "z" |
CASE_INSENSITIVE_ALPHANUMERIC |
การจัดเรียงตัวอักษรและตัวเลขคละกันโดยไม่คำนึงถึงตัวพิมพ์เล็กและตัวพิมพ์ใหญ่ตาม Code Point ของ Unicode แบบตัวพิมพ์เล็ก เช่น "2" < "A" < "b" < "X" < "z" |
NUMERIC |
ระบบจะแปลงค่ามิติข้อมูลเป็นตัวเลขก่อนการจัดเรียง เช่น ในการเรียงลําดับตัวเลข "25" < "100" และในการเรียงลําดับ ALPHANUMERIC "100" < "25" ค่ามิติข้อมูลที่ไม่ใช่ตัวเลขทั้งหมดจะมีค่าลําดับเท่ากันใต้ค่าตัวเลขทั้งหมด |
PivotOrderBy
จัดเรียงตามกลุ่มคอลัมน์ Pivot
การแสดง JSON |
{
"metricName": string,
"pivotSelections": [
{
object (PivotSelection )
}
]
} |
ช่อง |
metricName |
string
ในคำตอบสำหรับ "จัดเรียงตาม" ให้จัดเรียงแถวตามคอลัมน์นี้ ต้องเป็นชื่อเมตริกจากคําขอ
|
pivotSelections[] |
object (PivotSelection )
ใช้เพื่อเลือกชื่อมิติข้อมูลและ Pivot ของค่า หากมีการเลือก Pivot หลายรายการ ระบบจะจัดเรียงแถวที่มีคู่ชื่อและค่าของมิติข้อมูลการเลือก Pivot ทั้งหมดตรงกับคู่ชื่อและค่าของมิติข้อมูลของแถว
|
PivotSelection
คู่ชื่อและค่าของมิติข้อมูล แถวที่มีคู่ Pivot มิติข้อมูลนี้จะเรียงลําดับตามค่าของเมตริก
เช่น หาก pivots = ('browser', 'Chrome') และ metricName = "Sessions" ระบบจะจัดเรียงแถวตาม Sessions ใน Chrome
---------|----------|----------------|----------|----------------
| Chrome | Chrome | Safari | Safari
---------|----------|----------------|----------|----------------
Country | Sessions | Pages/Sessions | Sessions | Pages/Sessions
---------|----------|----------------|----------|----------------
US | 2 | 2 | 3 | 1
---------|----------|----------------|----------|----------------
Canada | 3 | 1 | 4 | 1
---------|----------|----------------|----------|----------------
การแสดง JSON |
{
"dimensionName": string,
"dimensionValue": string
} |
ช่อง |
dimensionName |
string
ต้องเป็นชื่อมิติข้อมูลจากคําขอ
|
dimensionValue |
string
จัดเรียงเฉพาะเมื่อมิติข้อมูลที่ระบุชื่อเป็นค่านี้
|
เนื้อหาของหน้าเว็บนี้ได้รับอนุญาตภายใต้ใบอนุญาตที่ต้องระบุที่มาของครีเอทีฟคอมมอนส์ 4.0 และตัวอย่างโค้ดได้รับอนุญาตภายใต้ใบอนุญาต Apache 2.0 เว้นแต่จะระบุไว้เป็นอย่างอื่น โปรดดูรายละเอียดที่นโยบายเว็บไซต์ Google Developers Java เป็นเครื่องหมายการค้าจดทะเบียนของ Oracle และ/หรือบริษัทในเครือ
อัปเดตล่าสุด 2025-07-26 UTC
[null,null,["อัปเดตล่าสุด 2025-07-26 UTC"],[[["\u003cp\u003eOrderBys determine the sorting of rows in a response, based on metrics, dimensions, or pivots.\u003c/p\u003e\n"],["\u003cp\u003eYou can order by metrics (e.g., event count), dimensions (e.g., event name), or pivot column groups.\u003c/p\u003e\n"],["\u003cp\u003eSorting can be done in ascending or descending order, specified by the \u003ccode\u003edesc\u003c/code\u003e boolean field.\u003c/p\u003e\n"],["\u003cp\u003eDimension sorting offers alphanumeric, case-insensitive alphanumeric, and numeric order types.\u003c/p\u003e\n"],["\u003cp\u003ePivotOrderBy allows sorting within specific pivot column groups based on metric values.\u003c/p\u003e\n"]]],["This content details various methods for sorting data rows in a response, known as \"OrderBys.\" Sorting can be based on metrics (`MetricOrderBy`) or dimensions (`DimensionOrderBy`). Dimensions can be ordered alphanumerically, case-insensitively, or numerically (`OrderType`). `PivotOrderBy` allows sorting by metric values within pivot column groups, using `PivotSelection` to specify dimension-value pairs for focused sorting. `OrderBys` can also be applied in descending order, indicated by the `desc` field.\n"],null,["# OrderBy\n\n- [JSON representation](#SCHEMA_REPRESENTATION)\n- [MetricOrderBy](#MetricOrderBy)\n - [JSON representation](#MetricOrderBy.SCHEMA_REPRESENTATION)\n- [DimensionOrderBy](#DimensionOrderBy)\n - [JSON representation](#DimensionOrderBy.SCHEMA_REPRESENTATION)\n- [OrderType](#OrderType)\n- [PivotOrderBy](#PivotOrderBy)\n - [JSON representation](#PivotOrderBy.SCHEMA_REPRESENTATION)\n- [PivotSelection](#PivotSelection)\n - [JSON representation](#PivotSelection.SCHEMA_REPRESENTATION)\n\nOrder bys define how rows will be sorted in the response. For example, ordering rows by descending event count is one ordering, and ordering rows by the event name string is a different ordering.\n\n| JSON representation |\n|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| ``` { \"desc\": boolean, // Union field `one_order_by` can be only one of the following: \"metric\": { object (/analytics/devguides/reporting/data/v1/rest/v1beta/OrderBy#MetricOrderBy) }, \"dimension\": { object (/analytics/devguides/reporting/data/v1/rest/v1beta/OrderBy#DimensionOrderBy) }, \"pivot\": { object (/analytics/devguides/reporting/data/v1/rest/v1beta/OrderBy#PivotOrderBy) } // End of list of possible types for union field `one_order_by`. } ``` |\n\n| Fields ||\n|-------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `desc` | `boolean` If true, sorts by descending order. |\n| Union field `one_order_by`. Specify one type of order by for `OrderBy`. `one_order_by` can be only one of the following: ||\n| `metric` | `object (`[MetricOrderBy](/analytics/devguides/reporting/data/v1/rest/v1beta/OrderBy#MetricOrderBy)`)` Sorts results by a metric's values. |\n| `dimension` | `object (`[DimensionOrderBy](/analytics/devguides/reporting/data/v1/rest/v1beta/OrderBy#DimensionOrderBy)`)` Sorts results by a dimension's values. |\n| `pivot` | `object (`[PivotOrderBy](/analytics/devguides/reporting/data/v1/rest/v1beta/OrderBy#PivotOrderBy)`)` Sorts results by a metric's values within a pivot column group. |\n\nMetricOrderBy\n-------------\n\nSorts by metric values.\n\n| JSON representation |\n|----------------------------------|\n| ``` { \"metricName\": string } ``` |\n\n| Fields ||\n|----------------|----------------------------------------------------|\n| `metric``Name` | `string` A metric name in the request to order by. |\n\nDimensionOrderBy\n----------------\n\nSorts by dimension values.\n\n| JSON representation |\n|-------------------------------------------------------------------------------------------------------------------------------|\n| ``` { \"dimensionName\": string, \"orderType\": enum (/analytics/devguides/reporting/data/v1/rest/v1beta/OrderBy#OrderType) } ``` |\n\n| Fields ||\n|-------------------|----------------------------------------------------------------------------------------------------------------------------------------------|\n| `dimension``Name` | `string` A dimension name in the request to order by. |\n| `order``Type` | `enum (`[OrderType](/analytics/devguides/reporting/data/v1/rest/v1beta/OrderBy#OrderType)`)` Controls the rule for dimension value ordering. |\n\nOrderType\n---------\n\nRule to order the string dimension values by.\n\n| Enums ||\n|---------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `ORDER_TYPE_UNSPECIFIED` | Unspecified. |\n| `ALPHANUMERIC` | Alphanumeric sort by Unicode code point. For example, \"2\" \\\u003c \"A\" \\\u003c \"X\" \\\u003c \"b\" \\\u003c \"z\". |\n| `CASE_INSENSITIVE_ALPHANUMERIC` | Case insensitive alphanumeric sort by lower case Unicode code point. For example, \"2\" \\\u003c \"A\" \\\u003c \"b\" \\\u003c \"X\" \\\u003c \"z\". |\n| `NUMERIC` | Dimension values are converted to numbers before sorting. For example in NUMERIC sort, \"25\" \\\u003c \"100\", and in `ALPHANUMERIC` sort, \"100\" \\\u003c \"25\". Non-numeric dimension values all have equal ordering value below all numeric values. |\n\nPivotOrderBy\n------------\n\nSorts by a pivot column group.\n\n| JSON representation |\n|-------------------------------------------------------------------------------------------------------------------------------------------------|\n| ``` { \"metricName\": string, \"pivotSelections\": [ { object (/analytics/devguides/reporting/data/v1/rest/v1beta/OrderBy#PivotSelection) } ] } ``` |\n\n| Fields ||\n|-----------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `metric``Name` | `string` In the response to order by, order rows by this column. Must be a metric name from the request. |\n| `pivot``Selections[]` | `object (`[PivotSelection](/analytics/devguides/reporting/data/v1/rest/v1beta/OrderBy#PivotSelection)`)` Used to select a dimension name and value pivot. If multiple pivot selections are given, the sort occurs on rows where all pivot selection dimension name and value pairs match the row's dimension name and value pair. |\n\nPivotSelection\n--------------\n\nA pair of dimension names and values. Rows with this dimension pivot pair are ordered by the metric's value.\n\nFor example if pivots = ('browser', 'Chrome') and metricName = \"Sessions\", then the rows will be sorted based on Sessions in Chrome. \n\n ---------|----------|----------------|----------|----------------\n | Chrome | Chrome | Safari | Safari\n ---------|----------|----------------|----------|----------------\n Country | Sessions | Pages/Sessions | Sessions | Pages/Sessions\n ---------|----------|----------------|----------|----------------\n US | 2 | 2 | 3 | 1\n ---------|----------|----------------|----------|----------------\n Canada | 3 | 1 | 4 | 1\n ---------|----------|----------------|----------|----------------\n\n| JSON representation |\n|---------------------------------------------------------------|\n| ``` { \"dimensionName\": string, \"dimensionValue\": string } ``` |\n\n| Fields ||\n|--------------------|----------------------------------------------------------------|\n| `dimension``Name` | `string` Must be a dimension name from the request. |\n| `dimension``Value` | `string` Order by only when the named dimension is this value. |"]]