試用 Google Analytics 的 MCP 伺服器。從
GitHub 安裝,詳情請參閱
公告。
WebhookNotification
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
設定長時間執行作業資源,在資源更新時,將 Google Analytics Data API 的 webhook 通知傳送至 webhook 伺服器。
通知設定包含私密值,只有 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 伺服器收到通知時,應在 5 秒內回覆 HTTP 回應狀態碼 200。 您必須提供 URI 才能使用 Webhook 通知。 這類要求會包含 ID 權杖,用於驗證服務帳戶 google-analytics-audience-export@system.gserviceaccount.com 。如要進一步瞭解 ID 權杖,請參閱 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;如果是 Google Cloud Functions 以外的 webhook 伺服器,則應忽略授權代管者標頭中的 ID 權杖 (如果不需要的話)。
|
channelToken |
string
選用設定。管道符記是任意字串值,且字串長度不得超過 64 個半形字元。管道權杖可讓您驗證 Webhook 通知的來源。這可防止訊息遭到冒用。管道權杖會在 webhook POST 要求的 X-Goog-Channel-Token HTTP 標頭中指定。 使用 webhook 通知時,不需要管道權杖。
|
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2025-07-26 (世界標準時間)。
[null,null,["上次更新時間:2025-07-26 (世界標準時間)。"],[[["\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. |"]]