There are two parts to sending data to Google Analytics using the Measurement Protocol:
This document describes how the transport and payload are formatted.
You send data using the Measurement Protocol by making HTTP POST requests to the following endpoint:
To send an event, issue the following
POST https://www.google-analytics.com/mp/collect payload_data
BODYof the request. The body should be
JSON. See Payload.
The Measurement Protocol always returns a
2xx status code if the
request was received. The Measurement Protocol does not return an error code if
the payload data was malformed, or if the data in the payload was incorrect or
was not processed by Google Analytics.
Data is sent to Google Analytics using the Measurement Protocol Data in two parts:
- Query parameters
To create a new secret, navigate in the Google Analytics UI to:
We recommend that you keep these private to your organization. If
you deploy the measurement protocol client-side, you should
JSON post body
Optional. A unique identifier for a user. See User-ID for cross-platform analysis for more information on this identifier.
Optional. A Unix timestamp (in microseconds) for the time to associate
with the event. This should only be set to record events that happened
in the past. This value can be overridden via
||Optional. The user properties for the measurement. See User properties for more information.|
Optional. Set to
||Required. An array of event items. Up to 25 events can be sent per request. See the events reference for all valid events.|
||Required. The name for the event. See the events reference for all options.|
||Optional. The parameters for the event. See events for the suggested parameters for each event.|
Recommended values for certain events
Some events have recommended parameters. See events for the recommended parameters for all supported events.
Reserved event names
The following event names are reserved and cannot be used:
Reserved parameter names
The following parameter names are reserved and cannot be used:
Additionally, parameter names cannot begin with:
Reserved user property names
The following user property names are reserved and cannot be used:
Additionally, user property names cannot begin with: