Essayez le serveur MCP pour Google Analytics. Installez-le depuis
GitHub et consultez l'
annonce pour en savoir plus.
WebhookNotification
Restez organisé à l'aide des collections
Enregistrez et classez les contenus selon vos préférences.
Configure une ressource d'opération de longue durée pour envoyer une notification webhook de l'API Google Analytics Data à votre serveur webhook lorsque la ressource est mise à jour.
Les configurations de notification contiennent des valeurs privées et ne sont visibles que par votre projet GCP. Différents projets GCP peuvent associer différentes notifications de webhook à la même ressource d'opération de longue durée.
Représentation JSON |
{
"uri": string,
"channelToken": string
} |
Champs |
uri |
string
Facultatif. Adresse Web qui recevra la notification du webhook. Cette adresse recevra des requêtes POST à mesure que l'état de la ressource d'opération de longue durée changera. La requête POST contient à la fois une version JSON de la ressource d'opération de longue durée dans le corps et un champ sentTimestamp . Le code temporel envoyé spécifie les microsecondes Unix depuis l'époque à laquelle la requête a été envoyée. Cela vous permet d'identifier les notifications rejouées. Exemple d'URI : https://us-central1-example-project-id.cloudfunctions.net/example-function-1 . L'URI doit utiliser HTTPS et pointer vers un site disposant d'un certificat SSL valide sur le serveur Web. La longueur maximale de la chaîne de l'URI doit être de 128 caractères et ne doit utiliser que les caractères de la liste d'autorisation de la RFC 1738. Lorsque votre serveur webhook reçoit une notification, il doit répondre avec un code d'état de réponse HTTP 200 dans les cinq secondes. Un URI est nécessaire pour utiliser les notifications webhook. Les requêtes envoyées à ce serveur webhook contiennent un jeton d'ID authentifiant le compte de service google-analytics-audience-export@system.gserviceaccount.com . Pour en savoir plus sur les jetons d'identification, consultez la page https://cloud.google.com/docs/authentication/token-types#id. Pour Google Cloud Functions, cela vous permet de configurer votre fonction pour qu'elle nécessite une authentification. Dans Cloud IAM, vous devez accorder les autorisations du compte de service aux rôles Demandeur Cloud Run (roles/run.invoker ) et Demandeur Cloud Functions (roles/cloudfunctions.invoker ) pour que la requête post du webhook puisse transmettre l'authentification Google Cloud Functions. Cette API peut envoyer des notifications webhook à des URI arbitraires. Pour les serveurs webhook autres que Google Cloud Functions, ce jeton d'identification dans l'en-tête de l'autorisation doit être ignoré s'il n'est pas nécessaire.
|
channelToken |
string
Facultatif. Le jeton de canal est une valeur de chaîne arbitraire et doit comporter 64 caractères maximum. Les jetons de canal vous permettent de vérifier la source d'une notification webhook. Cela permet d'éviter que le message ne soit falsifié. Le jeton de chaîne sera spécifié dans l'en-tête HTTP X-Goog-Channel-Token de la requête POST du webhook. Vous n'avez pas besoin d'un jeton de canal pour utiliser les notifications webhook.
|
Sauf indication contraire, le contenu de cette page est régi par une licence Creative Commons Attribution 4.0, et les échantillons de code sont régis par une licence Apache 2.0. Pour en savoir plus, consultez les Règles du site Google Developers. Java est une marque déposée d'Oracle et/ou de ses sociétés affiliées.
Dernière mise à jour le 2025/07/26 (UTC).
[null,null,["Dernière mise à jour le 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. |"]]