Technical Guides By Anacoic team April 2, 2026 25 min read Reviewed Nov 28, 2026

Server-side tracking and GDPR: a practical guide

How to gate server-side events on consent, keep personal data to a minimum and record what you sent, and what Anacoic does and doesn't do for you.

Illustration for the article “Server-side tracking and GDPR: a practical guide”

Direct Answer: GDPR-compliant server-side tracking requires enforcing consent in your own code before an event is sent, not just in the consent banner. Each event carries the visitor’s consent choices. Your code decides which destinations may receive it and which fields they get. You keep a record of what was sent, to whom, and on what basis for processing. Server-side tracking doesn’t conflict with GDPR, but it isn’t exempt from it either.

Moving tracking server-side is not a privacy workaround. When one piece of your own code sits between the browser and every destination, you have a single place to apply consent, data minimization and purpose limitation. That only helps if you build those rules in from the start.

This guide covers how a team can build that pipeline, from collecting consent to deciding what gets sent and keeping a record of it. Most of it is logic your site or server runs, whatever tool delivers the events. What Anacoic’s gateway does and doesn’t do with consent is set out separately in What Anacoic’s gateway does with consent. This is technical guidance for operators, not professional advice. Check binding compliance decisions with your Data Protection Officer or privacy counsel.


Table of Contents


Why Server-Side Tracking Is Not a Privacy Workaround

There is a persistent misconception that server-side tracking exists to bypass privacy controls. In reality, the opposite is true — when implemented correctly, server-side tracking gives you more privacy control than client-side tracking ever could.

The client-side problem

With traditional JavaScript-based tracking, here is what happens:

User clicks "Buy Now"
  → Browser fires Meta Pixel
  → Browser fires Google Tag
  → Browser fires TikTok Pixel
  → Browser fires analytics tag
  → Each tag sends whatever data it can access
  → No centralized control over what gets sent

Every tag running in the browser has access to the full page context: URL, cookies, referrer, user agent, and anything in the DOM. Even with a consent banner, client-side enforcement is fragile. A misconfigured tag manager or a third-party script can leak data before consent logic executes.

The server-side advantage

When you move tracking to a server-side architecture, the data path changes fundamentally:

User clicks "Buy Now"
  → Browser sends event to YOUR first-party endpoint
  → Your code checks the visitor's consent
  → Your code strips fields not covered by consent
  → Your code forwards the filtered payload to each permitted destination
  → Your code logs what was sent, to whom, and why

The browser never talks directly to third-party ad platforms. Your server-side code becomes the single enforcement point for consent policy. This is not a workaround. It is one way to build in data protection by design, which Article 25 of the GDPR asks for.

What regulators actually care about

Regulators do not care whether your tracking is client-side or server-side. They care about:

  1. Is there a lawful basis for processing?
  2. Does the data subject have meaningful control?
  3. Is data collection proportionate to the stated purpose?
  4. Can you demonstrate what you collected and why?

Server-side tracking does not automatically satisfy these requirements. It gives you one place in your own code where you can meet them, instead of many tags in the browser.


A privacy-compliant server-side tracking implementation is organized around consent tiers — graduated levels of data collection and processing that map directly to what the user has agreed to.

Diagram showing a consent-gated signal pipeline: user consent at three tiers (necessary, analytics, marketing) determines which data is collected, then a first-party gateway enforces policy rules including data minimization and purpose limitation before routing to destinations, with an audit trail recording what was sent and why.

A consent-first pipeline applies the visitor’s choices before anything is sent, so every delivery decision follows a written rule and can be checked later.

This tier covers processing that is strictly necessary for the service to function. Under GDPR, this does not require consent — it falls under the legitimate interest or contractual necessity basis.

Data collected at Tier 1:

  • Page URL and referrer (for navigation)
  • Session identifier (first-party, short-lived)
  • Basic error telemetry
  • Cart state for e-commerce transactions

What this does NOT include: User profiling, cross-session tracking, advertising identifiers, or behavioral analytics.

Analytics consent covers measurement and performance optimization. The user has agreed that you can track how they use your site beyond what is strictly necessary.

Additional data collected at Tier 2:

  • Scroll depth, time on page
  • Navigation paths and funnel progression
  • Device type, viewport, connection quality
  • Aggregated conversion events

Marketing consent permits data processing for advertising purposes, including retargeting, lookalike audience building, and cross-platform attribution.

Additional data collected at Tier 3:

  • Hashed email address (SHA-256)
  • Hashed phone number
  • External click identifiers (fbclid, gclid, ttclid)
  • Customer lifetime value signals
  • Product interest and purchase behavior

How the tiers map to destination delivery

Write down which tier each destination needs. Here is an example policy a team might set. Not every destination receives the same data:

DestinationRequired Consent TierData Received
Error monitoringTier 1 (Necessary)Page URL, error details, session ID
First-party analyticsTier 2 (Analytics)Page views, funnels, scroll depth, device
Google Analytics 4Tier 2 (Analytics)Events, user properties, session data
Meta Conversions APITier 3 (Marketing)Hashed PII, event data, click IDs
Google Ads Enhanced ConversionsTier 3 (Marketing)Hashed email, conversion value
TikTok Events APITier 3 (Marketing)Hashed PII, event data, click IDs

The code that decides what to send has to apply this policy, before anything reaches an ad platform. If a visitor has only granted analytics consent, their event can go to your analytics tool but should not reach any ad platform. That includes Meta and Google Ads.

That decision is yours to build. Anacoic’s gateway does not apply a policy like this: it sends each event it receives to every destination you’ve switched on, and it doesn’t skip a destination because of the visitor’s consent. So an event for a visitor who hasn’t agreed to marketing shouldn’t be sent to the gateway at all. The gateway also doesn’t send to GA4. See What Anacoic’s gateway does with consent for what it does handle.


GDPR Requirements That Apply to Server-Side Tracking

Moving tracking to server-side does not exempt you from GDPR. Every core principle still applies. Here is how each one maps to a server-side implementation.

Lawful basis for processing (Article 6)

You need a valid basis for processing for every processing activity. For server-side tracking, the most common bases are:

  • Consent (Art. 6(1)(a)): Required for analytics and marketing tracking. Must be freely given, specific, informed, and unambiguous.
  • Legitimate interest (Art. 6(1)(f)): May cover essential operational analytics (like error monitoring), but requires a documented Legitimate Interest Assessment (LIA).
  • Contractual necessity (Art. 6(1)(b)): Covers processing needed to fulfill a purchase — e.g., transaction logging for order confirmation.

Practical rule: If the data processing serves your business intelligence or advertising goals rather than the user’s direct need, you need consent.

Data minimization (Article 5(1)(c))

You must collect only the data that is adequate, relevant, and necessary for each stated purpose. Server-side tracking makes this enforceable:

  • At collection: Only capture fields appropriate for the granted consent tier
  • In your server-side code: Strip fields that are not needed for a specific destination
  • At dispatch: Send each destination only the fields it actually requires

For example, a purchase sent to Meta CAPI needs the event name, the value and the match keys, such as a hashed email. It does not need scroll depth, time on page, or navigation history. Strip these before you send the event.

Purpose limitation (Article 5(1)(b))

Data collected for analytics cannot be repurposed for marketing without additional consent. In a server-side setup, this means:

  • Tag each event with its consent tier and declared purpose at collection time
  • Before sending, check that each destination’s purpose matches the consented purpose
  • Do not merge analytics-consented data into marketing audience pipelines

Storage limitation (Article 5(1)(e))

Personal data must not be kept longer than necessary. This applies to:

  • Event logs: Retain raw event data only for the period needed for analytics processing, then aggregate or delete
  • Hashed PII: Even hashed data is personal data under GDPR — apply retention limits
  • Delivery logs: Keep the delivery records you need for accountability, but strip PII from them after a defined period

Right to erasure (Article 17)

If a user requests deletion under the “right to be forgotten,” you must be able to:

  1. Identify all data associated with that user across your tracking pipeline
  2. Delete or anonymize it within a reasonable timeframe
  3. Confirm deletion to the user

Server-side tracking can help here, if your own code keeps a record of what was collected and where each event was sent. With client-side tracking, each tag sends data on its own, so it’s harder to trace where a visitor’s data went.

Data protection by design (Article 25)

GDPR Article 25 requires that data protection be built into processing systems from the start, not bolted on afterward. A server-side pipeline gives you a natural place to do that.

A well-designed server-side pipeline puts Article 25 into practice:

  • Consent is checked before data enters the processing pipeline
  • Minimization is applied in your server-side code, not in a tag manager
  • Purpose limitation is built into the routing logic, not only a policy document
  • Delivery records are written as events are sent, not assembled after the fact

CCPA and US State Privacy Considerations

While GDPR is consent-first, US privacy laws follow an opt-out model. Your server-side pipeline needs to handle both paradigms.

Do Not Sell / Do Not Share (CCPA/CPRA)

Under CCPA, “sharing” personal information includes passing it to ad platforms for ads targeted on a person’s activity across websites, even if no money changes hands (California Attorney General, CCPA FAQ). When a user opts out:

  • Your code must stop sending identifiers (hashed email, phone) to ad platforms
  • Contextual, non-personal event data (page view, product category) may still be sent
  • The opt-out must be respected across all downstream destinations

Global Privacy Control (GPC)

The Global Privacy Control signal is a browser-level opt-out. The California Attorney General says covered businesses must honor it as a valid request to opt out of sale and sharing. Your server-side pipeline should:

  1. Detect the Sec-GPC: 1 header on inbound requests
  2. Treat it as an opt-out of sale/sharing
  3. Downgrade the consent tier to exclude marketing destinations
  4. Log that GPC was detected and honored

Handling more than one law

US state privacy laws differ in their details: what counts as a sale, which opt-out signals must be honored, and what a business must document. Check the text of each law that applies to you rather than a summary table, and note the date you checked it.

A practical rule for your own code: work out which rules apply to each visitor, from their location and the choices they’ve made, and apply the strictest. That is easier to manage in one place on your server than across many tags in the browser.


Your consent management platform (CMP) is the front door of the entire pipeline. If consent collection is flawed, nothing downstream can fix it.

Under GDPR, a compliant consent banner must:

  • ✅ Present a clear choice: Accept, Reject, or Customize — with equal visual weight
  • ✅ Not use dark patterns (pre-checked boxes, confusing “Accept All” prominence)
  • ✅ Explain purposes clearly in plain language
  • ✅ Allow granular selection (analytics and marketing as separate choices)
  • ✅ Be dismissable without penalty (dismissal = no consent = Tier 1 only)
  • ❌ Not block page access behind a “consent wall” (unless justified)
  • ❌ Not treat scroll or continued browsing as consent

GDPR defines consent as specific and informed (Article 4(11)), so bundled consent (“Accept all cookies” with no other choice) is risky. Granular consent gives each purpose its own toggle:

┌─────────────────────────────────────────┐
│  We use cookies and tracking to improve  │
│  your experience and measure performance │
│                                          │
│  ☑ Necessary        (always on)          │
│  ☐ Analytics         (optional)          │
│  ☐ Marketing         (optional)          │
│                                          │
│  [ Save Preferences ]  [ Accept All ]    │
└─────────────────────────────────────────┘

Each toggle maps directly to a consent tier. When the user saves preferences, this consent state is stored and propagated to every subsequent event.

You must be able to prove that consent was given, when, and for what purposes. Store:

  • Consent record: User ID or anonymous ID, timestamp, version of consent notice, selected tiers
  • Consent proof: The exact text or version of the privacy notice the user saw
  • Withdrawal record: If the user later revokes consent, record the timestamp and update all downstream processing

This consent state must be attached to every event that enters your server-side pipeline. Your code reads it before making any delivery decision.


Gateway-Level Policy Enforcement

The core rule of consent-first server-side tracking: consent must be applied where events are sent, not just in the banner.

A consent banner that nothing downstream respects is a paperwork checkbox, not a technical control. This section describes logic your own site or server runs before it calls any delivery service. To see where a gateway fits, read how Anacoic works.

Every event your server-side code handles should include a consent object. This is an example of an internal format, not a payload for any particular service:

{
  "event": "purchase",
  "consent": {
    "necessary": true,
    "analytics": true,
    "marketing": false
  },
  "data": {
    "page_url": "/checkout/confirmation",
    "order_value": 149.00,
    "email_hash": "a1b2c3...",
    "fbclid": "abc123",
    "session_id": "s_98765"
  }
}

Your code processes this as follows:

  1. Read the consent object. This user has consented to analytics but not marketing.
  2. Match destinations to required consent. Meta CAPI requires marketing consent. GA4 requires analytics consent.
  3. Filter the payload per destination:
    • GA4 receives: page_url, order_value, session_id
    • Meta CAPI: blocked entirely (no marketing consent)
  4. Log the delivery decision with consent state, timestamp, and destination.

Even when a destination is permitted under the user’s consent, your code should still apply data minimization, sending only what the destination actually needs:

FieldGA4 (Tier 2)Meta CAPI (Tier 3)Error Monitor (Tier 1)
page_url✅✅✅
order_value✅✅❌
email_hash❌✅❌
fbclid❌✅❌
session_id✅❌❌
scroll_depth✅❌❌
error_stack❌❌✅

Field-level filtering like this is simple to write in one server-side function. It is much harder to keep consistent across many tags in a client-side tag manager.

Destination-specific data formatting

Each ad platform has its own data requirements and hashing specifications. Whatever sends the events has to normalize the data to match:

  • Meta CAPI: SHA-256 hashed email (lowercase, trimmed), hashed phone (digits only, with the country code), per Meta’s customer information parameters
  • Google Enhanced Conversions: SHA-256 hashed email, address components
  • TikTok Events API: SHA-256 hashed email, hashed phone

Hashing in one place means it is applied the same way every time, and email addresses and phone numbers aren’t sent to ad platforms in plain text. For implementation details on specific platforms, see our guides on Meta CAPI vs TikTok Events and Google Ads Enhanced Conversions.


Anacoic’s gateway doesn’t decide whether an event may be sent. It sends each event it receives to every destination you’ve switched on. Consent and the basis for processing are still yours to set up. If a visitor hasn’t agreed to marketing, don’t send their event to the gateway, or send it only after they agree.

What the gateway does handle:

  • Personal details hashed first. Email addresses and phone numbers are hashed with SHA-256 at the gateway before they’re sent on.
  • Consent from your banner. The ana.js tracker accepts the visitor’s choices with anacoic.consent(...), using Google Consent Mode v2 names: ad_storage, analytics_storage, ad_user_data and ad_personalization. The choices apply to later events.
  • First-party cookies only with consent. The gateway sets its own first-party cookies only when the event says ad_storage is granted. With no consent signal, it sets none.
  • Consent passed on to Google Ads. Google Ads (available on request) receives the visitor’s ad_user_data and ad_personalization choices. When ad_user_data is denied, the gateway leaves out the hashed email and phone it would otherwise send there.
  • A short delivery log. The gateway keeps the latest 100 delivery log entries per gateway, for up to 30 days, with each destination’s status. Logs show the names of the match keys sent, never their values. They don’t record consent state, so they are not a consent audit trail.

The gateway sends to Meta’s Conversions API today. Google Ads is available on request. TikTok, Snapchat, LinkedIn, Pinterest, Reddit, X and Microsoft are in beta: not yet tried with a real ad account. It doesn’t send to GA4.

When you send an event from your server, pass consent next to the event. The gateway reads match keys from user:

await fetch('https://edge.anacoic.com/track', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'X-Gateway-ID': 'YOUR_GATEWAY_ID'
  },
  body: JSON.stringify({
    event_name: 'Purchase',
    event_id: 'order_10482',
    custom_data: { value: 149.00, currency: 'EUR' },
    user: { email: 'customer@example.com' }, // hashed with SHA-256 at the gateway
    consent: { ad_user_data: 'granted', ad_personalization: 'denied' }
  })
});

Only make this call once your own code has checked that the visitor’s consent allows it.


Logging, Audit Trail, and Accountability

GDPR Article 5(2) requires that you can demonstrate compliance with all processing principles. This is the accountability principle, and it calls for documentation, not just good intentions.

What to log for GDPR accountability

Every delivery decision your own code makes should produce an audit record that your team stores. Anacoic’s delivery log is not this record: it keeps only recent entries and no consent state. Here is an example of what your record could hold:

{
  "timestamp": "2026-04-02T14:32:18Z",
  "request_id": "req_a1b2c3",
  "event_type": "purchase",
  "consent_state": {
    "necessary": true,
    "analytics": true,
    "marketing": false
  },
  "deliveries": [
    {
      "destination": "ga4",
      "status": "delivered",
      "fields_sent": ["page_url", "order_value", "session_id"],
      "fields_stripped": ["email_hash", "fbclid"],
      "consent_basis": "analytics"
    },
    {
      "destination": "meta_capi",
      "status": "blocked",
      "reason": "no_marketing_consent"
    }
  ]
}

This log proves:

  • What event was processed
  • What consent was in effect at the time
  • What was sent to each destination (and what was stripped)
  • Which deliveries were blocked and why

How server-side tracking makes auditing easier

With client-side tracking, auditing means working out what each JavaScript tag collected and where it sent it. There is no central record. A data protection authority asking “show me what data you sent to Meta about user X” is hard to answer.

When your own server-side code writes the records above:

  • Every outbound delivery is logged in one place
  • Field-level records show exactly what was transmitted
  • Consent state at the time of delivery is attached to each record
  • Blocked deliveries are recorded alongside successful ones

A question like that becomes a lookup in your own records instead of an investigation.

Retention and cleanup

Audit logs themselves should have a retention policy. GDPR doesn’t set the periods; it asks that personal data be kept no longer than the purpose needs (Article 5(1)(e)). Decide and write down a period for each:

  • Delivery logs with PII references: Keep them only as long as you need them to check deliveries, then anonymize
  • Aggregated delivery statistics: Keep them for as long as you may need to show how processing worked
  • Consent records: Keep them for as long as you rely on the consent, and as long after as you may need to prove it was given

Before you change anything, run the free tracking check: it shows which tags load on your site and whether a consent banner is set up. Once events flow, Watch (early access) compares the purchases Meta received with your store orders every day, so you notice if a consent change cuts them off.

Implementation Checklist

Use this checklist when building or auditing a privacy-compliant server-side tracking pipeline:

  • Consent banner offers granular choice (necessary, analytics, marketing as separate toggles)
  • Accept and Reject buttons have equal visual prominence
  • Consent state is stored with timestamp and notice version
  • Consent can be withdrawn at any time, and withdrawal takes effect immediately
  • GPC (Sec-GPC: 1) header is detected and honored as opt-out

Data collection

  • Every event payload includes the user’s current consent state
  • Tier 1 (necessary) data collection is limited to operational essentials
  • No PII is collected at Tier 1 or Tier 2 (PII requires Tier 3 marketing consent)
  • All identifiers use first-party scope (not third-party cookies)

Enforcement in your code

  • Your code checks consent state before sending any event
  • Destinations are mapped to required consent tiers
  • Fields are stripped per-destination based on both consent tier and data minimization rules
  • PII is hashed before it is sent to any ad platform
  • Events from users with no consent (or Tier 1 only) are never sent to marketing destinations, or to a service that forwards to them

Audit and accountability

  • Every delivery decision is logged with consent state, fields sent, fields stripped, and destination
  • Blocked deliveries are logged with the reason for blocking
  • Audit logs are queryable by user identifier for erasure requests
  • Log retention policy is documented and enforced
  • Regular audits check that what your code sends matches documented policy

Documentation

  • Privacy policy accurately describes server-side processing, destinations, and purposes
  • Records of Processing Activities (ROPA) are updated to include server-side tracking
  • Data Processing Agreements (DPAs) are in place with all destination platforms
  • Legitimate Interest Assessment is documented for any Tier 1 processing beyond strict necessity

Common Compliance Mistakes in Server-Side Setups

Moving tracking server-side is a strong privacy foundation, but it does not guarantee compliance. Check your own setup for these six mistakes.

The mistake: “We moved everything server-side, so we don’t need a consent banner anymore.”

Why it is wrong: Server-side processing of personal data still requires a lawful basis. The data subject’s PII is still being processed — the only difference is where. If you are tracking users for analytics or marketing purposes, you still need consent (under GDPR) or must honor opt-out rights (under CCPA).

2. Sending full payloads to every destination

The mistake: Your server-side code receives event data and forwards the complete payload to every destination platform, regardless of what each platform needs.

Why it is wrong: This violates data minimization. Meta does not need scroll depth. GA4 does not need hashed phone numbers. Each destination should receive only the fields it requires for its stated purpose.

The mistake: Event tracking begins when the page loads. Consent state is applied retroactively.

Why it is wrong: Under GDPR, no processing beyond strict necessity should happen before consent is granted. If your script fires analytics events on page load and the user has not yet interacted with the consent banner, you have already violated the regulation.

The fix: On page load, only Tier 1 (necessary) events fire. Analytics and marketing events queue until consent is confirmed, then either send or discard.

4. Logging PII in audit trails indefinitely

The mistake: Audit logs contain raw email addresses or unhashed identifiers and are retained forever.

Why it is wrong: Logs containing PII are themselves personal data subject to GDPR. Retain them only for the period needed for accountability, then anonymize or delete.

The mistake: User grants marketing consent, receives a consent cookie, then withdraws consent. But the cookie (or stored consent state) is not updated in real time, so events continue to flow to marketing destinations.

Why it is wrong: GDPR requires that withdrawal of consent be as easy as giving it (Article 7(3)). Your code must pick up the new consent state at once and stop sending marketing events.

6. No DPA with destination platforms

The mistake: You are sending personal data to Meta, Google, and TikTok via server-side APIs but have not executed a Data Processing Agreement with each platform.

Why it is wrong: GDPR Article 28 requires a DPA with every processor who handles personal data on your behalf. Ad platforms provide these — you need to sign them.


FAQ

Is server-side tracking GDPR compliant by default?

No. Server-side tracking is a technical architecture, not a compliance status. It gives you one place to apply consent, control fields and keep records, but you still need consent collection, data minimization, purpose limitation, and documentation. The architecture enables compliance; the implementation determines it.

Yes. Under GDPR, you need consent for any non-essential processing of personal data, regardless of where the processing happens. Under CCPA, you need to provide opt-out mechanisms. The consent banner is the user-facing control; your server-side code has to act on what the visitor chose. They work together.

It depends on the scope. Basic operational analytics (error rates, page load times) may qualify under legitimate interest with a documented Legitimate Interest Assessment. But behavioral analytics — session recording, funnel analysis, user profiling — almost certainly requires consent under GDPR. The distinction hinges on whether the processing serves the user’s expectation or your business intelligence goals.

How does server-side tracking handle the right to erasure?

If your own code records what it collected and where it sent each event, you have one place to look. When a user requests erasure, you can: (1) delete their data from your systems, (2) identify which platforms received their data, and (3) ask each platform to delete it, using whatever deletion process that platform offers. That is easier than tracing data that client-side tags sent on their own.

If the user has not interacted with the consent banner, treat them as Tier 1 only (necessary). No analytics or marketing data should be collected or forwarded. Events that require higher consent tiers should either not fire at all or be queued and discarded if consent is never granted. Never default to full tracking with retroactive consent.

Is hashed email still personal data under GDPR?

Yes. Pseudonymized data (including hashed email addresses) is still personal data under GDPR because it can be re-identified. Hashing is a security measure, not an anonymization technique. You still need a lawful basis to process hashed PII, and it still counts toward your data minimization and purpose limitation obligations.

How do I handle users in jurisdictions with different privacy laws?

Your own code should work out the user’s jurisdiction (based on IP geolocation or explicit selection) and apply the strictest applicable rules. For a user in the EU, apply GDPR opt-in requirements. For a user in California, honor CCPA opt-out rights and GPC signals. For users in less-regulated jurisdictions, apply your baseline privacy policy. Checking this per request in one server-side function saves you from keeping separate tracking setups per region. The server-side tracking guide covers the delivery side.


This guide is technical implementation guidance. It is not professional advice. Privacy regulations differ by jurisdiction and change frequently. Consult a qualified Data Protection Officer or privacy attorney for compliance decisions specific to your business.

Anacoic’s first-party gateway sends conversions server-side from your own subdomain and hashes email addresses and phone numbers with SHA-256 before sending them on. It doesn’t decide consent for you: the checks in this guide stay in your own code. You can also review the conversion data gap to understand what happens when privacy compliance and signal accuracy are treated as separate problems instead of one.

Next step

Ready to set it up? The docs walk through Watch and the gateway step by step.