Server Protocols
Server-side tracking sends data to analytics directly from your server, skipping the browser. It solves ad blocker problems, improves reliability, and tracks events that happen outside the browser like offline purchases or payment processing.
Why Server-Side Tracking
Client-Side Problems
Browser-based JavaScript tracking faces growing limits:
Ad blockers. Up to 40% of users run extensions that block analytics scripts. Significant data loss.
Browser restrictions. Safari, Firefox, and others limit cookies and tracking. Cookies expire after 7 days, third-party cookies are blocked.
Incomplete conversion data. Many key events happen outside the browser. Payment confirmation, returns, status changes. Without server-side tracking, this data is gone.
Server-Side Benefits
Key Benefits
100% data collection: Blockers can't stop your server.
Conversion accuracy: Track real transactions, not button clicks.
Data security: Sensitive info never reaches the browser.
Data enrichment: Add CRM, inventory, and other system data.
Measurement Protocol
What It Is
Measurement Protocol sends data directly to Google Analytics via HTTP requests. Instead of waiting for a user to visit and trigger JavaScript, you send the data yourself.
graph LR
A[Your Server] --> B[HTTP Request]
B --> C[Google Analytics]
C --> D[Reports & Dashboards]How It Works
Simple HTTP POST requests to a Google Analytics URL. Data appears in your reports.
Basic request:
POST https://www.google-analytics.com/mp/collect
?measurement_id=G-XXXXXXXXXX
&api_secret=YOUR_SECRET_KEY
{
"client_id": "123456.789012",
"events": [{
"name": "purchase",
"params": {
"value": 99.99,
"currency": "USD"
}
}]
}
Key Components
Measurement ID. Your data stream identifier in GA4. Find it in Admin → Data Streams → select stream → Measurement ID.
API Secret. Auth key. Created in Data Streams → Measurement Protocol API → Create new secret.
Client ID. Unique user identifier. Same value for all events from one user. Save it on first visit.
Common Events
Webhooks
What They Are
Webhooks are HTTP callbacks from external services. When something happens in a service (an order is paid, a contact is created), it sends a request to your server.
sequenceDiagram
participant S as Stripe/PayPal
participant W as Your Server
participant A as Analytics
S->>W: Webhook: Payment Successful
W->>W: Process Data
W->>A: Send to Analytics
W->>S: OK (200)Popular Webhooks
Payment systems:
| Service | Events | Use |
|---|---|---|
| Stripe | payment_intent.succeeded | Payment confirmation |
| PayPal | PAYMENT.CAPTURE.COMPLETED | Payment completion |
| Square | payment.created | New transaction |
E-commerce:
| Service | Events | Use |
|---|---|---|
| Shopify | orders/create | New order |
| WooCommerce | order.completed | Completed order |
| BigCommerce | store/order/created | Order creation |
Email and CRM:
| Service | Events | Use |
|---|---|---|
| Mailchimp | subscribe | New subscription |
| HubSpot | contact.creation | New contact |
| SendGrid | email.open | Email opened |
Setting Up Reception
Create a URL on your server to receive and process incoming requests.
Setup Steps
Create endpoint: A URL like
https://yoursite.com/webhooks/stripeConfigure in service: Set this URL in the webhook settings
Verify signature: Confirm the request is from the service
Process data: Extract what you need
Send to analytics: Use Measurement Protocol
Security
Signature verification. Most services sign webhooks with a secret key. Always verify.
Idempotency. Webhooks can arrive multiple times. Save event IDs and check for duplicates.
Quick response. Reply 200 OK fast and process async. Otherwise the service may retry.
Server-to-Server
API Integrations
Many services provide APIs. Unlike webhooks where the service notifies you, here you pull data.
When to use APIs:
- Need historical data
- Need more process control
- Webhooks unavailable or limited
- Need extra information
Common Integrations
Sync customer data:
- Deal stages → Events in analytics
- Lead status changes → Segment updates
- Closed deals → Transactions in GA4
Track email activity:
- Subscriptions → Sign-up events
- Email opens → Engagement events
- Email clicks → Traffic source
Accurate revenue tracking:
- Successful payments → Purchase events
- Refunds → Refund events
- Subscriptions → Recurring revenue
OAuth
Many APIs require OAuth. It gives your app access to data without sharing passwords.
OAuth flow:
graph TD
A[User] --> B[Authorize in Service]
B --> C[Grant Access]
C --> D[Receive Token]
D --> E[Use API]Practical Examples
Offline Conversions
Scenario: Customer ordered online, paid in store.
Solution:
- Save Client ID from GA on order creation
- POS system sends webhook on store payment
- Server forwards purchase event to GA with saved Client ID
- Reports show full funnel from first visit to payment
CRM and Analytics Sync
Scenario: Need to know which sources bring quality customers.
Solution:
- Save Client ID and source in CRM on first visit
- Manager changes lead status to "Qualified"
- CRM sends webhook with lead info
- Send custom event to GA with value = potential deal value
Subscription Tracking
Scenario: SaaS with monthly Stripe subscriptions.
Solution:
- Configure Stripe webhooks for subscription events
- Successful payment → purchase event
- Cancellation → churn event
- Renewal → renewal event
Full picture of LTV and retention in analytics.
Tools
No-Code
For non-developers:
| Tool | What It Does | Cost |
|---|---|---|
| Zapier | Connect services without code | From $19.99/mo |
| Make (Integromat) | Visual automation | From $9/mo |
| Segment | Unified tracking layer | From $120/mo |
| Stitch Data | ETL for analytics | Custom pricing |
Libraries
If you can write code:
Node.js: @google-analytics/data, universal-analyticsPython: google-analytics-python, pygaPHP: google/analytics-data, theiconic/php-ga-measurement-protocolRuby: google-api-client, ga-measurement-protocol
Debugging
Tools You Need
GA4 DebugView: Real-time event view during debugging
Postman: Manual API testing
RequestBin: Verify webhooks arrive correctly
Server logs: Always log important events
Common Mistakes
Duplicate Events
Problem: Same event sent multiple times.
Fix: Use unique event IDs. Check before sending.
Wrong Client ID
Problem: Each event creates a new user.
Fix: Save Client ID on first visit. Reuse it for all events.
Lost Context
Problem: Events arrive without traffic source.
Fix: Save UTM parameters and other attributes on first visit. Pass them with server events.
Hitting Limits
Problem: GA blocks requests due to rate limits.
Fix: Stay within limits. No more than 25 events per batch, no more than 1 request per second.
Privacy
GDPR
Server-side tracking still needs GDPR compliance:
- Get consent
- Store proof of consent
- Provide opt-out
- Delete data on request
Anonymization
What to anonymize:
- IP addresses (or skip them)
- Email addresses (use hash)
- Names and other PII
- Exact geolocation
Storage
Best practices:
- Store only the minimum
- Auto-delete old data
- Encrypt sensitive info
- Log data access
Getting Started
Step-by-Step Plan
Step 1: Audit current tracking
- What data is lost to blockers?
- What key events happen outside the browser?
- Which systems already send webhooks?
Step 2: Set priorities
- Start with key conversions (purchases, registrations)
- Add business-critical events
- Expand gradually
Step 3: Build infrastructure
- Create API secret in GA4
- Set up webhook endpoint
- Organize Client ID storage
Step 4: Test
- Use GA4 DebugView
- Test on a small sample
- Compare with current data
Step 5: Launch
- Watch the first days closely
- Set up anomaly alerts
- Document the process
Server-side tracking complements client-side, it doesn't replace it. Combined, they give the most complete picture of behavior and business performance.
Statable simplifies server-side setup. Auto-accept data from popular sources, normalize it for unified reports.
About AI participation in writing articles
This article, like many others on our site, was created, written and proofread by a team of developers. Of course, not without the participation of AI assistants. We don't hide this and believe that modern systems are already quite good at handling simple tasks and, relatively speaking, writing an article about Viewport yourself is quite strange. It won't come out significantly better and will take a lot of time. But providing basic understanding to beginner webmasters is necessary. Of course, after the article is written by assistants - there's always proofreading, and this is where not one or two people participate, and only after that the article is published.
Ready to Get 100% of Your Conversion Data?
Try Statable free. Server-side tracking without complex programming. Simple integrations, ready templates, full data control.
Ready to take control of your web analytics? Try Statable free for 30 days — no credit card required, full feature access, GDPR-compliant by default. Start your free trial or view a live demo.