Advertising TechProduction Architecture

Advertising Campaign & Attribution Automation

A pipeline that keeps campaign data, tracking parameters, and conversion events in one place you can trust.

My contribution
I owned the ingestion API, click-ID rules, dedupe logic, and reporting schema.
Technology
Python, FastAPI, PostgreSQL, Redis, Server-Side Events (S2S), Webhooks & REST APIs
Links
Not publicly available

01Problem

Campaign setups scatter, UTMs/click IDs get messy, and browser signals drop — so spend and conversions stop matching.

Approach. I standardized tracking params, validated pixel and webhook events, deduped browser + server conversions, and wrote clean rows into reporting tables — without shady redirects or policy games.

02Requirements

  • Normalize campaign taxonomy, UTM tags, and platform click identifiers (e.g., gclid, fbclid).
  • Support both client-side pixel events and server-to-server (S2S) conversion postbacks.
  • Deduplicate identical conversion events using deterministic event IDs.
  • Respect user consent states and platform advertising policies.

03Architecture

Traffic arrives on fast, transparent landing pages that capture consent state and campaign parameters. When a user completes an action, the backend emits a signed event to an ingestion queue. Workers validate the schema, check Redis for duplicate event keys within the attribution window, enrich the record with campaign metadata, and persist aggregated metrics to PostgreSQL.

  1. Campaign Sources
  2. Integration Layer
  3. Event Pipeline
  4. Attribution Store
  5. Analytics Dashboard

04Technology choices

FastAPI
Low-overhead async HTTP endpoints for high-concurrency webhook and event ingestion.
Redis
Fast idempotency checks and short-lived click-session state lookup.
PostgreSQL
ACID-compliant storage for attribution joins, audit logs, and reporting rollups.

05Implementation

  • Created strict Pydantic schemas for impression, click, lead, and conversion payloads.
  • Implemented idempotency keys combining event type, transaction ID, and timestamp buckets.
  • Built scheduled reconciliation jobs comparing ad-platform spend APIs against internal conversion logs.

06Security considerations

  • HMAC signature verification on all incoming webhook and postback endpoints.
  • PII hashing and minimization prior to forwarding conversion signals to ad platforms.
  • Strict adherence to platform terms—no cloaking, deceptive redirects, or non-consensual tracking.

07Challenges

  • Handling out-of-order events where conversion postbacks arrive before asynchronous click logs.
  • Maintaining accurate attribution when users switch devices or block third-party cookies.

08Results and lessons learned

Events validate cleanly, landing routes stay transparent, and conversion logs are auditable across channels.

Implemented as a reference and operational ad-tech architecture. Separating raw event ingestion from attribution modeling allows attribution rules to evolve without losing historical event integrity.