Hãy thử máy chủ MCP cho Google Analytics. Cài đặt từ
GitHub và xem
thông báo để biết thêm thông tin chi tiết.
WebhookNotification
Sử dụng bộ sưu tập để sắp xếp ngăn nắp các trang
Lưu và phân loại nội dung dựa trên lựa chọn ưu tiên của bạn.
Định cấu hình tài nguyên hoạt động chạy trong thời gian dài để gửi thông báo webhook từ API Dữ liệu Google Analytics đến máy chủ webhook của bạn khi tài nguyên cập nhật.
Cấu hình thông báo chứa các giá trị riêng tư và chỉ dự án GCP của bạn mới thấy được. Các dự án GCP khác nhau có thể đính kèm các thông báo webhook khác nhau vào cùng một tài nguyên hoạt động chạy trong thời gian dài.
Biểu diễn dưới dạng JSON |
{
"uri": string,
"channelToken": string
} |
Trường |
uri |
string
Không bắt buộc. Địa chỉ web sẽ nhận được thông báo webhook. Địa chỉ này sẽ nhận được các yêu cầu POST khi trạng thái của tài nguyên hoạt động chạy trong thời gian dài thay đổi. Yêu cầu POST sẽ chứa cả phiên bản JSON của tài nguyên thao tác chạy trong thời gian dài trong phần nội dung và trường sentTimestamp . Dấu thời gian đã gửi sẽ chỉ định số micro giây unix kể từ thời gian bắt đầu của đồng hồ mà yêu cầu được gửi; điều này cho phép bạn xác định thông báo phát lại. Ví dụ về URI là https://us-central1-example-project-id.cloudfunctions.net/example-function-1 . URI phải sử dụng HTTPS và trỏ đến một trang web có chứng chỉ SSL hợp lệ trên máy chủ web. URI phải có độ dài chuỗi tối đa là 128 ký tự và chỉ sử dụng các ký tự có trong danh sách cho phép theo RFC 1738. Khi nhận được thông báo, máy chủ webhook của bạn sẽ phản hồi bằng mã trạng thái phản hồi HTTP là 200 trong vòng 5 giây. Bạn phải có URI để sử dụng thông báo webhook. Các yêu cầu gửi đến máy chủ webhook này sẽ chứa mã thông báo nhận dạng xác thực tài khoản dịch vụ google-analytics-audience-export@system.gserviceaccount.com . Để tìm hiểu thêm về mã thông báo nhận dạng, hãy xem https://cloud.google.com/docs/authentication/token-types#id. Đối với Google Cloud Functions, việc này cho phép bạn định cấu hình hàm để yêu cầu xác thực. Trong Cloud IAM, bạn cần cấp quyền cho tài khoản dịch vụ cho vai trò Trình gọi Cloud Run (roles/run.invoker ) và Trình gọi Cloud Functions (roles/cloudfunctions.invoker ) để yêu cầu đăng webhook có thể vượt qua quy trình xác thực Google Cloud Functions. API này có thể gửi thông báo webhook đến các URI tuỳ ý; đối với các máy chủ webhook không phải là Google Cloud Functions, bạn nên bỏ qua mã nhận dạng này trong tiêu đề người mang mã uỷ quyền nếu không cần thiết.
|
channelToken |
string
Không bắt buộc. Mã thông báo kênh là một giá trị chuỗi tuỳ ý và phải có độ dài chuỗi tối đa là 64 ký tự. Mã thông báo kênh cho phép bạn xác minh nguồn của thông báo webhook. Điều này giúp ngăn chặn việc thư bị giả mạo. Mã thông báo kênh sẽ được chỉ định trong tiêu đề HTTP X-Goog-Channel-Token của yêu cầu POST webhook. Bạn không cần mã thông báo kênh để sử dụng thông báo webhook.
|
Trừ phi có lưu ý khác, nội dung của trang này được cấp phép theo Giấy phép ghi nhận tác giả 4.0 của Creative Commons và các mẫu mã lập trình được cấp phép theo Giấy phép Apache 2.0. Để biết thông tin chi tiết, vui lòng tham khảo Chính sách trang web của Google Developers. Java là nhãn hiệu đã đăng ký của Oracle và/hoặc các đơn vị liên kết với Oracle.
Cập nhật lần gần đây nhất: 2025-07-26 UTC.
[null,null,["Cập nhật lần gần đây nhất: 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. |"]]