Google Analytics Measurement Protocol
Send server-to-server and offline events to Google Analytics 4 using the Measurement Protocol with HIPAA compliance for healthcare data.
Overview
The Google Analytics Measurement Protocol destination allows you to send server-to-server and offline events directly to Google Analytics 4. This is particularly useful for tracking events that occur outside of standard web interactions, such as webhook events, server-side processing, or offline conversions.
Important Note: For standard web tracking, we recommend using the Google Analytics (GA4) destination instead. The Measurement Protocol destination is specifically designed for server-to-server and offline event tracking scenarios.
When to Use Measurement Protocol
Use the Google Analytics Measurement Protocol destination when you need to:
- Send events from webhooks or server-side processes
- Track offline conversions or interactions
- Associate server events with existing web sessions
- Send events from devices or systems where standard GA4 tracking isn't available
- Bridge online and offline user behavior
Setup and Configuration
Adding Google Analytics Measurement Protocol as a Destination
To add a destination:
- Navigate to the Destinations page in your Ours Privacy platform.
- Click Add destination and select Google Analytics Measurement Protocol as the destination type.
Required Configuration
You'll need to provide two key pieces of information:
1. Measurement ID
- Go to your Google Analytics 4 property
- Navigate to Admin > Data Streams
- Select your web stream
- Copy the Measurement ID (format:
G-XXXXXXXXXX)
2. API Secret
- In the same data stream settings
- Scroll down to Measurement Protocol API secrets
- Click Create to generate a new secret
- Copy the generated Secret value
Note: Sometimes GA4 can truncate your API Secret in the UI. Make sure you are copying over the entire value. The GA4 API Secret is typically 22 characters in total. Sending an incomplete API Secret will cause dispatches to fail.
Event Mapping Requirements
When configuring events for the Measurement Protocol destination, you'll be asked to map two critical identifiers:
Session ID (sid)
The session ID helps Google Analytics associate your server events with specific user sessions. This should be mapped to a field that contains the session identifier from your web tracking. This should always be set up as {{visitor.sid}}
Client ID (cid)
The client ID is the unique identifier for a user across sessions. This should be mapped to a field that contains the client identifier from your web tracking. This should always be set up as {{visitor.cid}}
Associating Server Events with Web Sessions
To properly associate server events with existing web sessions in Google Analytics, ensure you have a way to link webhook events to existing visitors. This typically involves:
- Capturing identifiers from web sessions: Store the
client_idandsession_idfrom your web tracking - Including these identifiers in server events: When sending events via webhooks or server-side processes, include the same
client_idandsession_id - Mapping in Ours Privacy: Configure the destination to map these fields correctly
Example Implementation
When a user completes a web form that triggers a server-side webhook:
// Ours Privacy mapping to associate back to same session id and client id:
{
"event_name": "form_processed",
"client_id": "{{visitor.cid}}",
"session_id": "{{visitor.sid}}"
}Event Tracking
Standard and Custom Events
You can send any standard GA4 events or custom events through the Measurement Protocol. Common use cases include:
- Purchase events: Track offline purchases or server-processed transactions
- Lead events: Track form submissions processed server-side
- Custom events: Track any business-specific interactions
Event Property Limitations
When sending events via Measurement Protocol, please note the following limitations:
- Each event can have a maximum of 20 event properties
- Each event property value must be fewer than 1,000 characters
- Event names are limited to 40 characters
- Event names cannot contain special characters, only underscores are permitted
Best Practices
- Use the standard GA4 destination for web events: Reserve the Measurement Protocol for server-side and offline events only
- Maintain consistent identifiers: Ensure
client_idandsession_idare consistent between web and server events - Send events promptly: For session attribution, send Measurement Protocol events within 24 hours of the session start
- Validate your setup: Use Google Analytics DebugView to verify events are being received correctly
Troubleshooting
-
Remove All Universal Analytics (UA) Scripts
Universal Analytics (UA) was deprecated in July 2023. Please ensure all UA scripts are removed before installing Ours Privacy.
-
Remove GA4 Tracking for the Account Connect via Ours Privacy
Since Ours Privacy automatically tracks page views and other events, you must remove any existing GA4 tracking scripts for the specific account connected to Ours Privacy to prevent duplicate event counts.
-
Consider Removing Other GA4 Accounts
If you have multiple GA4 accounts on the same page, we recommend removing them as well. This reduces the chance of conflicts and increase the compliance of your website.
-
Confirm correct inbound payload structure
Reference the inbound payload structure and ensure that the event name and any other inbound parameters are being mapped over correctly. An invalid or exempt event name will cause the dispatch to fail.
-
Ensure the API Secret and Measurement ID are correct
Dispatching an incorrect Measurement ID or API Secret will cause dispatches to fail.
-
Make sure mappings are set up correctly
The only requirements for this destination to work is that the API Secret and Measurement Protocol are correct, the event name is present and valid, and that the CID and SID are mapped correctly as noted above.
{{visitor.cid}}and{{visitor.sid}}.
How is this guide?