Sub topic 9
Server-side tracking and conversion APIs
This chapter assumes you know what a tag manager is, how a browser cookie works, and what a conversion event is. It also assumes you have read the earlier chapters on consent and first-party data.
What server-side tracking changes
In browser-side tracking, a script on the page sends each event straight from the visitor's browser to the ad platform. Ad blockers, browser tracking rules, and consent choices can all stop that request.
In server-side tracking, the browser sends events to a server you control. Your server then forwards the events to the ad platforms. A conversion API is the interface an ad platform provides for this. You send purchases, sign-ups, and other conversions to it from your server.
What you gain
- Control over data. You decide which fields leave your systems, so you can remove data the platform does not need.
- Better signal quality. Events from your order system or CRM do not depend on a script surviving in the browser. They also include offline conversions such as phone orders.
- Longer first-party cookie life. A cookie set by your server in an HTTP response is generally treated more favorably than one set by a script. Some browsers still cap the lifetime of script-set cookies.
- Faster pages. Fewer third-party scripts load in the browser.
What it does not change
Server-side tracking is not a way around consent. The law applies to the data and the purpose, not to where the code runs. If a visitor declined tracking, sending their data from your server is still a violation. Pass the consent state along with every event and check it before forwarding.
Browsers also work against hidden tracking. Routing requests through your own domain to disguise third-party tracking can be treated as a workaround, and platforms may restrict it.
Matching conversions to people
Conversion APIs usually match an event to an ad click or a user with identifiers. Common ones are a click ID, a hashed email address, and a hashed phone number. Hashing turns a value into a fixed-length string that cannot be read back directly. You must normalize the value first, so the same email always produces the same hash.
import hashlib
def hash_email(email: str) -> str:
"""Normalize and SHA-256 hash an email address before sending it to an ad platform."""
normalized = email.strip().lower()
return hashlib.sha256(normalized.encode("utf-8")).hexdigest()
print(hash_email(" [email protected] "))The function trims spaces and lowercases the address before hashing. Without that step, [email protected] and [email protected] would produce different hashes and fail to match.
Common errors
- Double counting. Sending the same conversion from the browser and from the server inflates results. Include a shared event ID so the platform can remove duplicates.
- Skipping normalization. Inconsistent casing, whitespace, or phone formats lower match rates.
- Ignoring consent. Forwarding every event regardless of consent state.
- Sending too much. Passing fields the platform does not need.
- Stale click IDs. Not storing the click ID at landing time means it is missing when the conversion happens later.
- No monitoring. Failed API calls fail silently unless you check the platform's event diagnostics.
A practical setup
- Capture the click ID and consent state at landing, and store them in a first-party cookie or session.
- Attach them to the order or lead record.
- When a conversion occurs, build the event with an event ID, a timestamp, and hashed identifiers.
- Forward it only if the stored consent allows it.
- Check the platform's match quality and deduplication reports each week.
Exercise
A retailer sends each purchase from the browser tag and also from its server through a conversion API. Reported conversions rise by about 80% but revenue does not change. What is the likely cause, and how do you fix it?
Show answer
The same purchases are probably counted twice. Send a shared event ID with both the browser and server versions of each event so the platform can deduplicate them, then check the platform's deduplication report.
Exercise
A team says that moving tracking to the server means it no longer needs a consent banner for advertising events. Is that correct?
Show answer
No. Consent rules apply to collecting and using the data, wherever the code runs. The server must check the visitor's stored consent before forwarding events or identifiers to an ad platform.