After going through validating events, you'll want to verify your implementation. The validation server validates that your events have the correct structure, but to verify that they are being sent correctly to your property, you'll need to do the following:
If you're not seeing your events after going through these steps, check troubleshooting for common implementation errors.
Send an event from a client
Choose your client:
In order for an event to be valid, it must have a client_id
that has already
been used to send an event from gtag.js
. You will need to capture this ID
client-side and include it in your call to the Measurement Protocol. In
send an event to your property, we use "client_id"
as the
client_id
. You will need to replace this with a real client_id
that comes
from gtag.js
.
Send an event to your property
After you have sent an event from a client and captured a valid client_id
,
you'll be ready to send an event using the Measurement Protocol. When verifying
your implementation, you should send the exact event that you're trying to
measure using the Measurement Protocol.
For example, the following sends a refund event:
const measurementId = `<measurement_id_value>`;
const apiSecret = `<secret_value>`;
fetch(`https://www.google-analytics.com/mp/collect?measurement_id=${measurementId}&api_secret=${apiSecret}`, {
method: "POST",
body: JSON.stringify({
"client_id": "XXXXXXXXXX.YYYYYYYYYY",
"events": [{
"name": "refund",
"params": {
"currency": "USD",
"value": "9.99",
"transaction_id": "ABC-123"
}
}]
})
});
Check the Realtime view
After sending an event using the Measurement Protocol, check the Realtime view for your property. Events typically show up within a few seconds.
Go to the Realtime view by opening Google Analytics, then going to Reports > Realtime in the left navigation. You'll want to focus on the bottom charts, such as "Event count by Event name" and "Conversions by Event name."
Check DebugView
If the Realtime view doesn't provide enough detail for you to verify your
implementation, enable debug mode in some test events by including the following
parameters in the params
collection so you can monitor and review the events
in DebugView:
"debug_mode": true
or"debug_mode": 1
"engagement_time_msec"
set to a positive number
For example, the following sends a refund with debug mode enabled:
const measurementId = `<measurement_id_value>`;
const apiSecret = `<secret_value>`;
fetch(`https://www.google-analytics.com/mp/collect?measurement_id=${measurementId}&api_secret=${apiSecret}`, {
method: "POST",
body: JSON.stringify({
"client_id": "XXXXXXXXXX.YYYYYYYYYY",
"events": [{
"name": "refund",
"params": {
"currency": "USD",
"value": "9.99",
"transaction_id": "ABC-123",
"engagement_time_msec": 1200,
"debug_mode": true
}
}]
})
});
After you send events with debug mode enabled, follow the instructions for monitoring events using DebugView to verify your implementation.