Google Analytics 4 (Dual-Track)
Complete GA4 integration: server-side Measurement Protocol + automatic client-side gtag.js loading.
Google Analytics 4 is the standard for web analytics. But like all browser-based tools, it misses events blocked by privacy tools.
Server-side GA4 integration ensures you capture everything.
Why GA4 Server-Side?
Client vs Server Comparison
| Aspect | Client-Side (gtag) | Server-Side (API) |
|---|---|---|
| Ad blocker resistant | No | Yes |
| Data accuracy | 70-85% | 95%+ |
| Setup complexity | Simple | Moderate |
| Real-time | Yes | Yes |
Best Practice: Use Both
****
Client-side gtag ā Captures in-session behavior + Server-side API ā Captures blocked events + backend events = Complete analytics picture ****Setup Guide
Step 1: Get Your Credentials
From Google Analytics:
- Go to analytics.google.com
- Click Admin (gear icon)
- Go to Data Streams ā Select your web stream
- Copy your Measurement ID (starts with G-)
- Scroll to Measurement Protocol API secrets
- Click Create and copy the API secret
Step 2: Connect in AdsMAA
- Go to Integrations ā Tracking & E-commerce
- Find Google Analytics 4 card
- Click Connect
- Enter your credentials:
| Field | What to Enter |
|---|---|
| Measurement ID | G-XXXXXXXXXX |
| API Secret | Your generated secret |
- Click Connect
Step 3: Verify Events
- Go to GA4 ā Reports ā Realtime
- Trigger an event on your website
- You should see it appear within seconds
Event Mapping
AdsMAA automatically translates events to GA4 format:
Standard Events
| AdsMAA Event | GA4 Event | Parameters |
|---|---|---|
| PageView | page_view | page_location, page_title |
| ViewContent | view_item | items[], currency, value |
| AddToCart | add_to_cart | items[], currency, value |
| InitiateCheckout | begin_checkout | items[], currency, value |
| Purchase | purchase | transaction_id, items[], value |
| Lead | generate_lead | currency, value |
| Search | search | search_term |
E-commerce Item Format
GA4 expects items in a specific format:
****
json { "event": "purchase", "params": { "transaction_id": "ORD-12345", "value": 99.99, "currency": "USD", "items": [ { "item_id": "SKU-001", "item_name": "Blue Shoes", "price": 99.99, "quantity": 1, "item_category": "Footwear" } ] } } ****We handle this translation automatically when you use our SDK.
E-commerce Tracking
Full Purchase Funnel
Track the complete customer journey:
| Stage | Event | Key Parameters |
|---|---|---|
| Browse | view_item | item_id, item_name |
| Interest | add_to_wishlist | items[] |
| Intent | add_to_cart | items[], value |
| Checkout | begin_checkout | items[], value |
| Payment | add_payment_info | payment_type |
| Purchase | purchase | transaction_id, value |
| Refund | refund | transaction_id, value |
Example: Track Purchase
****`javascript adsmai('track', 'Purchase', { orderId: 'ORD-12345', value: 149.99, currency: 'USD', products: [ { id: 'SKU-001', name: 'Running Shoes', price: 99.99, quantity: 1, category: 'Footwear' }, { id: 'SKU-002', name: 'Sports Socks', price: 25.00, quantity: 2, category: 'Accessories' } ] });
// Automatically sent to GA4 as 'purchase' event // With properly formatted items[] array ****`
Debugging
Check Event Delivery
-
GA4 Realtime Report
- Events should appear within 30 seconds
- Check event count and parameters
-
GA4 DebugView
- Admin ā Data Display ā DebugView
- Enable debug mode in your browser
- See detailed event parameters
-
AdsMAA Event Log
- Tracking ā Events ā Filter by GA4
- See delivery status and any errors
Common Issues
| Issue | Solution |
|---|---|
| Events not appearing | Verify Measurement ID is correct |
| Missing parameters | Check event is using correct format |
| Delayed data | Realtime is live; reports take 24-48h |
| Duplicate events | Enable deduplication in settings |
Recap
Here is what you learned:
- Server-side GA4 captures events missed by ad blockers
- Use both client and server for complete coverage
- Events auto-translate to GA4 format
- E-commerce tracking works out of the box
GA4 server-side integration ensures your analytics are complete and accurate.
Next step: Connect Shopify to sync your store data.
Key Takeaways
- 1Server-side Measurement Protocol bypasses ad blockers
- 2Client-side gtag.js loads automatically via our SDK
- 3Events sent to both channels simultaneously
- 4Automatic e-commerce event translation
Frequently Asked Questions
Will this create duplicate events in GA4?
Do I need gtag.js if I use server-side?
What about user_id for cross-device tracking?
Was this article helpful?
Continue Reading
Meta Pixel + CAPI (Dual-Track)
Complete Meta tracking: server-side CAPI + automatic client-side Pixel for maximum attribution.
integrationsUnified JavaScript SDK
One SDK for all platforms. Auto-loads Meta Pixel, GA4, and Clarity based on your connected integrations.
trackingConversion Tracking Deep Dive
Understand how server-side tracking works and why it captures 2x more data than browser pixels.