There are two parts to sending data to Google Analytics using the Measurement Protocol:
- The transport - where and how you send data
- The payload - the data you send
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 /mp/collect HTTP/1.1 HOST: www.google-analytics.com Content-Type: application/json <payload_data>
BODYof the request. 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
Measurement ID. The identifier for a Data Stream. Found in the Google
Analytics UI under:
Admin > Data Streams > choose your stream > Measurement ID
JSON post body
Required. Uniquely identifies a user instance of a web client. See send event to the Measurement Protocol.
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: