Google Analytics 4 Conversion Tracking
Sesamy integrates with Google Analytics 4 (GA4) Measurement Protocol to send purchase events directly to your GA4 property, enabling accurate conversion tracking and revenue attribution.
Overview
The Google Analytics 4 Measurement Protocol allows you to send events directly from your server to Google Analytics. This provides reliable, server-side tracking that complements browser-based tracking for a complete view of your conversions.
Benefits:
- Accurate revenue and conversion tracking
- Server-side tracking immune to ad blockers
- Enhanced ecommerce reporting
- Better attribution for marketing campaigns
- Reliable data for optimization
Learn more: Google Analytics 4 Measurement Protocol
Getting Started
Prerequisites
- An active Google Analytics 4 property
- Admin access to your GA4 property
- A data stream configured for your website
Setup Process
Step 1: Create an API Secret
- Sign in to Google Analytics
- Click Admin (gear icon in the bottom left)
- In the Property column, select Data Streams
- Click on your web data stream
- Scroll down to Measurement Protocol API secrets
- Click Create
- Enter a nickname for the secret (e.g., "Sesamy Integration")
- Click Create
- Copy the generated Secret value
Important
Copy the secret value immediately after creation. You won't be able to see it again later.
Step 2: Find Your Measurement ID
While still viewing your data stream settings:
- Look for Measurement ID at the top of the stream details
- It will be in the format
G-XXXXXXXXXX - Copy this ID
Step 3: Provide Credentials to Sesamy
Send the following information to your Sesamy account manager:
- API Secret: The secret value you generated
- Measurement ID: Your stream's measurement ID (G-XXXXXXXXXX)
Your account manager will configure the integration for you.
Events & Data
Purchase Event
Sesamy automatically sends a purchase event to Google Analytics 4 immediately after a transaction is completed on your platform.
Data Payload
The following data is included in each purchase event:
| Parameter | Description | Example |
|---|---|---|
| currency | The currency used for the transaction | "USD", "EUR", "SEK" |
| value | The total value of the transaction | 99.99 |
| tax | The tax amount for the transaction | 19.99 |
| transaction_id | Unique checkout ID for the purchase | "checkout_abc123" |
| coupon | The coupon code if one was used | "SAVE20" |
| items | Array of purchased items (see below) | [...] |
| client_id | Google Analytics client identifier | "123456789.1234567890" |
Items Array
Each item in the items array includes:
| Field | Description | Source |
|---|---|---|
| item_id | The product's SKU | Product SKU from your catalog |
| item_name | The product title | Product title |
| item_variant | The purchase option name | E.g., "Monthly", "Annual" |
| quantity | Number of items purchased | Typically 1 for subscriptions |
| price | Price per item | Item price |
Example payload:
{
"client_id": "123456789.1234567890",
"events": [
{
"name": "purchase",
"params": {
"currency": "SEK",
"value": 99.0,
"tax": 19.8,
"transaction_id": "checkout_abc123",
"coupon": "WELCOME10",
"items": [
{
"item_id": "premium-monthly",
"item_name": "Premium Subscription",
"item_variant": "Monthly",
"quantity": 1,
"price": 99.0
}
]
}
}
]
}Client ID Tracking
Automatic Tracking
The client_id parameter is crucial for connecting server-side events with user sessions in GA4.
Automatic capture when using:
- Sesamy.js library
- Sesamy web components
When checkout generation happens via Sesamy.js and our web components, the _ga parameter is automatically captured from the Google Analytics cookie and passed to the checkout process.
Custom Implementation
If you're using a custom implementation without Sesamy.js:
Extract the GA Client ID from the
_gacookie in the user's browserjavascript// The _ga cookie format: GA1.2.123456789.1234567890 // Extract the last two parts: 123456789.1234567890 const gaCookie = document.cookie.split('; ').find((row) => row.startsWith('_ga=')); if (gaCookie) { const parts = gaCookie.split('.'); const clientId = `${parts[2]}.${parts[3]}`; // Pass this as _ga parameter to checkout }Pass the
_gaparameter when creating a checkout:https://checkout.sesamy.com/?_ga=123456789.1234567890Sesamy will use this value as the
client_idwhen sending events to GA4
TIP
Without the _ga parameter, a random client_id will be generated, which means the purchase event won't be connected to the user's browsing session in GA4 reports.
Integration Features
Server-Side Tracking
All events are sent server-to-server from Sesamy's backend to Google Analytics 4:
- Reliable delivery: Events are sent even if the user closes their browser
- Ad blocker resistant: Server-side tracking bypasses browser-based blockers
- Better accuracy: Ensures all purchases are tracked
- Privacy compliant: Server-side tracking can be configured to respect user privacy preferences
Enhanced Ecommerce
Purchase events follow GA4's ecommerce event schema, enabling:
- Revenue reporting in GA4 ecommerce reports
- Product performance analysis
- Purchase funnel visualization
- Marketing attribution
Monitoring & Verification
Test Your Integration
After setup is complete:
- Make a test purchase on your platform
- Go to Google Analytics
- Navigate to Reports > Realtime
- Look for the purchase event in the real-time event stream
- Verify the event parameters and revenue values
DebugView
For detailed testing, use GA4's DebugView:
- In Google Analytics, go to Configure > DebugView
- Make a test purchase
- View the detailed event parameters and validation
Delay in Reports
While events appear in Realtime and DebugView immediately, they may take 24-48 hours to appear in standard reports.
Verify in Reports
After 24-48 hours, check:
- Monetization Overview: Reports > Monetization > Overview
- Ecommerce Purchases: Reports > Monetization > Ecommerce purchases
- Purchase Event: Reports > Engagement > Events (filter for "purchase")
Event Deduplication
If you're also using browser-side GA4 tracking (gtag.js or Google Tag Manager), ensure events are deduplicated:
- Each purchase event should include a unique
transaction_id - GA4 automatically deduplicates events with the same
transaction_id - Sesamy uses the checkout ID as the transaction_id for this purpose
Troubleshooting
Events Not Appearing
If events aren't showing up in GA4:
- Check Realtime reports first (not standard reports)
- Verify your credentials:
- Measurement ID is correct
- API Secret is valid
- API Secret hasn't been deleted or regenerated
- Test with DebugView for more detailed error information
- Wait 24-48 hours for events to appear in standard reports
Missing Client ID Connection
If purchases aren't connecting to user sessions:
- Verify the
_gaparameter is being passed to checkout - Check that the GA cookie exists on your site
- Ensure GA4 is installed and working on your website
- Test with browser developer tools to see cookie values
Revenue Not Showing
If events appear but revenue is zero or missing:
- Verify the
valueparameter is being sent with purchase events - Check that currency codes are valid (ISO 4217 format)
- Ensure items array includes price information
- Review the event in DebugView for parameter validation errors
Best Practices
- Use Both Client and Server Tracking: Implement browser-side GA4 tracking alongside Measurement Protocol for complete coverage
- Pass the GA Client ID: Always include the
_gaparameter for proper attribution - Test Thoroughly: Use DebugView to verify all parameters are correct
- Monitor Regularly: Check reports weekly to ensure tracking is working
- Document Your Setup: Keep a record of your Measurement ID and which API Secret you're using
- Respect Privacy: Configure tracking in compliance with GDPR and privacy regulations
Data Privacy & Compliance
GDPR Considerations
- Server-side tracking should respect user consent preferences
- Ensure you have proper consent before tracking purchases
- Consider implementing consent mode for GA4
IP Anonymization
GA4 automatically anonymizes IP addresses in compliance with privacy regulations.
Support
For assistance with Google Analytics 4 integration:
- Contact your Sesamy account manager
- Consult Google's Measurement Protocol documentation
- Reach out to Sesamy support for technical issues