ลองใช้เซิร์ฟเวอร์ MCP สำหรับ Google Analytics ติดตั้งจาก
GitHub และดูรายละเอียดเพิ่มเติมได้ที่
ประกาศ
WebhookNotification
จัดทุกอย่างให้เป็นระเบียบอยู่เสมอด้วยคอลเล็กชัน
บันทึกและจัดหมวดหมู่เนื้อหาตามค่ากำหนดของคุณ
กําหนดค่าทรัพยากรการดำเนินการที่ทำงานต่อเนื่องเพื่อส่งการแจ้งเตือนเว็บฮุคจาก Google Analytics Data API ไปยังเซิร์ฟเวอร์เว็บฮุคเมื่อมีการอัปเดตทรัพยากร
การกําหนดค่าการแจ้งเตือนมีค่าส่วนตัวและจะแสดงเฉพาะในโปรเจ็กต์ GCP ของคุณเท่านั้น โปรเจ็กต์ GCP ที่แตกต่างกันอาจแนบการแจ้งเตือน Webhook ที่แตกต่างกันไปยังทรัพยากรการดำเนินการแบบต่อเนื่องเดียวกัน
การแสดง JSON |
{
"uri": string,
"channelToken": string
} |
ช่อง |
uri |
string
ไม่บังคับ ที่อยู่เว็บที่จะได้รับการแจ้งเตือน Webhook ที่อยู่นี้จะได้รับการร้องขอ POST เมื่อสถานะของทรัพยากรการดำเนินการที่ทำงานต่อเนื่องมีการเปลี่ยนแปลง คําขอ POST จะมีทั้งทรัพยากรการดำเนินการแบบต่อเนื่องเวอร์ชัน JSON ในส่วนเนื้อหาและช่อง sentTimestamp การประทับเวลาที่ส่งจะระบุไมโครวินาที Unix นับจากจุดเริ่มต้นที่ส่งคำขอ ซึ่งจะช่วยให้คุณระบุการแจ้งเตือนที่เล่นซ้ำได้ ตัวอย่าง URI คือ https://us-central1-example-project-id.cloudfunctions.net/example-function-1 URI ต้องใช้ HTTPS และชี้ไปยังเว็บไซต์ที่มีใบรับรอง SSL ที่ถูกต้องในเว็บเซิร์ฟเวอร์ URI ต้องมีความยาวสตริงสูงสุด 128 อักขระ และใช้เฉพาะอักขระในรายการที่อนุญาตจาก RFC 1738 เมื่อเซิร์ฟเวอร์ Webhook ได้รับการแจ้งเตือน ระบบจะตอบกลับด้วยรหัสสถานะการตอบกลับ HTTP 200 ภายใน 5 วินาที ต้องระบุ URI เพื่อใช้การแจ้งเตือนผ่านเว็บฮุค คำขอไปยังเซิร์ฟเวอร์ Webhook นี้จะมีโทเค็นระบุตัวตนที่ตรวจสอบสิทธิ์บัญชีบริการ google-analytics-audience-export@system.gserviceaccount.com ดูข้อมูลเพิ่มเติมเกี่ยวกับโทเค็นระบุตัวตนได้ที่ https://cloud.google.com/docs/authentication/token-types#id สําหรับ Google Cloud Functions ตัวเลือกนี้จะช่วยให้คุณกําหนดค่าฟังก์ชันให้ต้องใช้การตรวจสอบสิทธิ์ได้ ใน Cloud IAM คุณจะต้องมอบสิทธิ์บัญชีบริการให้กับบทบาทผู้เรียกใช้ Cloud Run (roles/run.invoker ) และผู้เรียกใช้ Cloud Functions (roles/cloudfunctions.invoker ) เพื่อให้คําขอโพสต์ Webhook ผ่านการตรวจสอบสิทธิ์ของ Google Cloud Functions API นี้สามารถส่งการแจ้งเตือน Webhook ไปยัง URI ที่กำหนดเองได้ สำหรับเซิร์ฟเวอร์ Webhook ที่ไม่ใช่ Google Cloud Functions คุณควรละเว้นโทเค็นระบุตัวตนนี้ในส่วนหัวของผู้ถือสิทธิ์การให้สิทธิ์หากไม่จำเป็น
|
channelToken |
string
ไม่บังคับ โทเค็นของช่องคือค่าสตริงที่กำหนดเองและต้องมีขนาดสตริงสูงสุด 64 อักขระ โทเค็นของช่องช่วยให้คุณยืนยันแหล่งที่มาของการแจ้งเตือนผ่านเว็บฮุคได้ ซึ่งจะช่วยป้องกันไม่ให้ข้อความถูกปลอมแปลง ระบบจะระบุโทเค็นของช่องในส่วนหัว X-Goog-Channel-Token HTTP ของคำขอ POST ของเว็บฮุค คุณไม่จำเป็นต้องใช้โทเค็นของช่องเพื่อใช้การแจ้งเตือนผ่านเว็บฮุค
|
เนื้อหาของหน้าเว็บนี้ได้รับอนุญาตภายใต้ใบอนุญาตที่ต้องระบุที่มาของครีเอทีฟคอมมอนส์ 4.0 และตัวอย่างโค้ดได้รับอนุญาตภายใต้ใบอนุญาต Apache 2.0 เว้นแต่จะระบุไว้เป็นอย่างอื่น โปรดดูรายละเอียดที่นโยบายเว็บไซต์ Google Developers Java เป็นเครื่องหมายการค้าจดทะเบียนของ Oracle และ/หรือบริษัทในเครือ
อัปเดตล่าสุด 2025-07-26 UTC
[null,null,["อัปเดตล่าสุด 2025-07-26 UTC"],[[["\u003cp\u003eWebhook notifications can be configured for long-running operations in the Google Analytics Data API to send updates to your server.\u003c/p\u003e\n"],["\u003cp\u003eThese notifications are project-specific and include a JSON payload with operation details and a timestamp.\u003c/p\u003e\n"],["\u003cp\u003eThe webhook configuration requires a URI using HTTPS with a valid SSL certificate, and optionally, a channel token for verification.\u003c/p\u003e\n"],["\u003cp\u003eWhen receiving a notification, your server should respond with an HTTP 200 status code within 5 seconds.\u003c/p\u003e\n"],["\u003cp\u003eAuthentication for Google Cloud Functions is provided through an ID token representing the service account \u003ccode\u003egoogle-analytics-audience-export@system.gserviceaccount.com\u003c/code\u003e, while other webhook servers can ignore this token.\u003c/p\u003e\n"]]],["This document outlines the configuration for webhook notifications from the Google Analytics Data API. You can set up a webhook server (`uri`) to receive POST requests containing long-running operation resource updates in JSON format, along with a `sentTimestamp`. The `uri` must be HTTPS with a valid SSL certificate and is required for webhook notifications. Optionally, use a `channelToken` for source verification, which is included in the `X-Goog-Channel-Token` header. Notifications will include an ID token for authentication.\n"],null,["# WebhookNotification\n\n- [JSON representation](#SCHEMA_REPRESENTATION)\n\nConfigures a long-running operation resource to send a webhook notification from the Google Analytics Data API to your webhook server when the resource updates.\n\nNotification configurations contain private values \\& are only visible to your GCP project. Different GCP projects may attach different webhook notifications to the same long-running operation resource.\n\n| JSON representation |\n|---------------------------------------------------|\n| ``` { \"uri\": string, \"channelToken\": string } ``` |\n\n| Fields ||\n|------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `uri` | `string` Optional. The web address that will receive the webhook notification. This address will receive POST requests as the state of the long running operation resource changes. The POST request will contain both a JSON version of the long running operation resource in the body and a `sentTimestamp` field. The sent timestamp will specify the unix microseconds since the epoch that the request was sent; this lets you identify replayed notifications. An example URI is `https://us-central1-example-project-id.cloudfunctions.net/example-function-1`. The URI must use HTTPS and point to a site with a valid SSL certificate on the web server. The URI must have a maximum string length of 128 characters \\& use only the allowlisted characters from [RFC 1738](https://www.rfc-editor.org/rfc/rfc1738). When your webhook server receives a notification, it is expected to reply with an HTTP response status code of 200 within 5 seconds. A URI is required to use webhook notifications. Requests to this webhook server will contain an ID token authenticating the service account `google-analytics-audience-export@system.gserviceaccount.com`. To learn more about ID tokens, see \u003chttps://cloud.google.com/docs/authentication/token-types#id\u003e. For Google Cloud Functions, this lets you configure your function to require authentication. In Cloud IAM, you will need to grant the service account permissions to the Cloud Run Invoker (`roles/run.invoker`) \\& Cloud Functions Invoker (`roles/cloudfunctions.invoker`) roles for the webhook post request to pass Google Cloud Functions authentication. This API can send webhook notifications to arbitrary URIs; for webhook servers other than Google Cloud Functions, this ID token in the authorization bearer header should be ignored if it is not needed. |\n| `channel``Token` | `string` Optional. The channel token is an arbitrary string value and must have a maximum string length of 64 characters. Channel tokens allow you to verify the source of a webhook notification. This guards against the message being spoofed. The channel token will be specified in the `X-Goog-Channel-Token` HTTP header of the webhook POST request. A channel token is not required to use webhook notifications. |"]]