Ad Tracking & Tagging
The Complete Technical Guide
What is Ad Tracking?
Ad tracking is the technical infrastructure that records, measures, and reports on digital advertising events — impressions, clicks, and conversions — as they occur across the programmatic ecosystem. Without tracking, advertisers would have no visibility into campaign performance, and publishers would have no basis for billing.
Tracking is the foundation of digital advertising economics. Every impression served, every click registered, and every conversion attributed flows through a complex network of ad servers, tracking pixels, cookies, and redirects — all working together in milliseconds to ensure accurate measurement.
- Impression: An ad is rendered and has the opportunity to be seen. The foundation of CPM (cost per thousand impressions) billing.
- Click: A user actively clicks on an ad, navigating to the advertiser's destination. The basis for CPC (cost per click) pricing.
- Conversion: A desired action after ad exposure — purchase, sign-up, download, etc. The ultimate measure of campaign success.
📡 Ad Servers: The Central Hub of Tracking
Ad servers are the technology platforms that store creatives, make delivery decisions, and — most critically — track all ad events. Every impression, click, and conversion flows through the ad server, which records the event, applies attribution logic, and reports performance.
How Ad Servers Track
JS or iframe code on publisher page
Receives request, records impression
Ad rendered to user
Fires to confirm delivery
Types of Ad Tags
Most common for display ads. Ad server returns JavaScript that writes the ad into the page. Enables rich media, viewability measurement, and dynamic content. Supports: impressions, clicks, viewability, interaction tracking.
Ad loads in a sandboxed iframe. Isolates ad from publisher page, preventing interference but limiting some interactivity. Supports: impressions, clicks (with redirects).
Simple 1x1 transparent image used for impression tracking. Often used as a backup or for third-party verification. Supports: impressions only (no clicks).
👁️ Impression Tracking: How It Works
An impression is counted when the ad tag fires and the ad server records the request. But not all impressions are equal — viewability, bot detection, and counting methodologies vary significantly.
The Impression Flow
1. Page Loads: User's browser requests the publisher page.
2. Ad Tag Executes: Browser encounters the ad tag (JavaScript or iframe) and makes a request to the ad server.
3. Ad Server Records Impression: The ad server logs the request with metadata: timestamp, user agent, IP, publisher ID, placement ID, and campaign ID.
4. Creative Returned: Ad server returns the creative (image, video, HTML5) to the browser.
5. Creative Renders: Browser displays the ad.
6. Viewability Measurement: JavaScript within the ad measures if/when the ad becomes viewable (≥50% visible for ≥1 second).
7. Billing Occurs: For CPM campaigns, the impression is counted for billing.
Impression Counting Methods
- Server-Side Counting: Ad server counts impressions when the tag request is received. Fast but vulnerable to bot traffic and pre-fetching.
- Client-Side Counting: JavaScript fires a pixel after the creative loads. More accurate but may miss if creative doesn't load.
- Viewable Impression Counting: Only counts impressions that meet MRC viewability standards (≥50% visible for ≥1 second). Required for viewability guarantees.
🖱️ Click Tracking: The Redirect Chain
Click tracking is more complex than impression tracking because it involves a redirect chain that passes through multiple systems before reaching the destination. Each click must be recorded by the ad server, often multiple verification vendors, and finally the destination URL.
The Click Redirect Flow
On creative
Ad server click tracker
IAS/DV click trackers
Advertiser destination
https://adserver.com/click?campaign=12345&creative=67890&click_id=abc123&redirect=https://advertiser.com/productWhen a user clicks, the browser navigates to this URL. The ad server records the click, then redirects (HTTP 302) to the next URL in the chain — often a verification vendor, then finally the advertiser's landing page. All of this happens in milliseconds.
Click Tracking Methods
- HTTP Redirect (302): Most common. Ad server returns a 302 redirect to the destination URL. Click is recorded server-side.
- JavaScript Click Tracker: JavaScript fires a tracking pixel in the background before redirecting. Allows for additional data collection but can be blocked by ad blockers.
- Click Macro Substitution: DSPs and SSPs use macros (e.g., ${CLICK_URL}) to dynamically insert click trackers into creative URLs.
✅ Conversion Tracking: Attribution & Measurement
Conversion tracking connects ad exposures (impressions and clicks) to desired user actions — purchases, sign-ups, app installs, or any other business outcome. This is the most critical tracking function for performance advertising.
Types of Conversions
User clicks an ad and later completes a conversion on the advertiser's site. The most direct and trackable conversion type. Lookback windows typically 7-30 days.
User sees an ad (impression) but does not click, then later converts. More controversial but important for upper-funnel measurement. Lookback windows typically 1-7 days.
Conversions that happen within a mobile app — purchases, level completions, registrations. Tracked via mobile measurement partners (MMPs) like AppsFlyer, Kochava, Branch.
How Conversion Tracking Works
1. Ad Impression/Click: User sees or clicks an ad. Ad server records the event with a unique identifier (click_id or impression_id).
2. Cookie/Device ID Stored: A cookie (or device ID) is set in the user's browser containing tracking identifiers.
3. User Converts: Days later, user completes a purchase on the advertiser's site.
4. Conversion Pixel Fires: On the conversion page, a tracking pixel (JavaScript or image) fires to the ad server, passing the conversion data (order value, product ID).
5. Cookie Matching: Ad server reads the cookie/device ID and matches it to previous impressions/clicks from that user.
6. Attribution Applied: Ad server applies attribution logic (last-click, first-click, multi-touch) to assign credit to the appropriate ad.
7. Reporting: Conversion is reported in campaign dashboards.
Lookback Windows & Attribution Models
- Click Lookback Window: How many days after a click will a conversion be attributed? Common: 7 days, 14 days, 30 days, 90 days.
- View Lookback Window: How many days after an impression (without click) will a conversion be attributed? Common: 1 day, 3 days, 7 days.
- Attribution Models:
- Last-Click: 100% credit to last touchpoint before conversion
- First-Click: 100% credit to first touchpoint
- Linear: Equal credit to all touchpoints
- Time-Decay: More credit to touchpoints closer to conversion
- Position-Based: 40% first, 40% last, 20% distributed across middle
- Data-Driven: Algorithmic credit based on historical conversion paths
🍪 Cookies: The Backbone of Tracking
Cookies are small text files stored in the browser that enable tracking across sessions and sites. They are fundamental to ad tracking — enabling frequency capping, retargeting, and attribution. However, the cookie landscape is rapidly changing.
Types of Cookies in Advertising
Set by the domain the user is visiting (e.g., publisher.com). Used for session management, analytics, and first-party audience building. Surviving privacy changes.
Set by a domain different from the one the user is visiting (e.g., adserver.com on publisher.com). Enable cross-site tracking, retargeting, and frequency capping. Being phased out by all major browsers.
Mobile app identifiers — IDFA (iOS) and GAID (Android). Enable tracking across apps. Apple's ATT framework now requires opt-in for IDFA access.
Hashed email-based identifiers (UID2, RampID). Replace third-party cookies with consented, deterministic identifiers. Require user login.
Cookie Syncing
Cookie syncing is the process of matching user IDs across different systems (DSPs, SSPs, DMPs) to enable coordinated tracking and targeting. When a user visits a site, multiple platforms set their own cookies. To share data about that user, they must "sync" these IDs.
1. User visits publisher site with SSP and DMP tags.
2. SSP sets a cookie (SSP_ID). DMP sets a cookie (DMP_ID).
3. SSP sends a sync request to DSP:
https://dsp.com/sync?ssp_id=abc123&redirect=https://ssp.com/sync4. DSP reads its own cookie (DSP_ID) and maps it to SSP_ID.
5. DSP redirects back to SSP with match confirmation.
6. Future bid requests can now pass the mapped user ID, enabling DSP to recognize the user.
📊 Tracking in Programmatic: OpenRTB & Macros
In programmatic auctions, tracking is built into the OpenRTB protocol through macros — placeholders that are dynamically replaced with real values when the impression is served.
Key Tracking Macros
- ${AUCTION_ID}: Unique ID for the auction — used for reconciliation across systems
- ${AUCTION_PRICE}: Clearing price of the impression (in CPM)
- ${AUCTION_BID_ID}: Unique ID for the bid within the auction
- ${AUCTION_IMP_ID}: Impression ID from the bid request
- ${AUCTION_SEAT_ID}: Buyer seat identifier
- ${AUCTION_AD_ID}: Creative identifier
Win Notices & Billing Notices
GET https://dsp.com/win?auction_id=12345&price=1.80📌 burl (Billing Notice URL): Called for server-side impression counting and billing. Used by DSPs to record spend.
GET https://dsp.com/bill?auction_id=12345&price=1.80
📱 Mobile & App Tracking: SDKs & MMPs
Mobile app tracking differs significantly from web tracking. Instead of cookies, apps use device IDs (IDFA/GAID) and SDKs (Software Development Kits) to track user behavior.
Mobile Measurement Partners (MMPs)
MMPs like AppsFlyer, Kochava, Branch, and Singular provide the infrastructure for mobile attribution. They track app installs, in-app events, and cross-channel performance.
In mobile app
Apple/Google Play
Device ID captured
MMP receives data
MMP matches to ad source
Device IDs vs. Cookies
- IDFA (Identifier for Advertisers) - iOS: Apple's identifier for advertising. With iOS 14.5+, apps must request permission via App Tracking Transparency (ATT). Opt-in rates ~20-30%.
- GAID (Google Advertising ID) - Android: Google's identifier. Users can reset or opt out of ad personalization.
- SKAdNetwork (Apple): Privacy-focused attribution framework for iOS. Provides aggregated, delayed conversion data without user-level tracking.
⚠️ Tracking Discrepancies: Why Numbers Don't Match
Tracking discrepancies are one of the most frustrating aspects of digital advertising — when the advertiser's ad server, publisher's ad server, and third-party verification vendors report different numbers for the same campaign.
Common Causes of Discrepancies
- Counting Methodologies: Server-side vs. client-side counting; viewable vs. served impressions
- Ad Blockers: Tags blocked before they can fire
- Latency & Timeouts: Slow page loads causing tags to time out
- Bot Traffic & Invalid Traffic: Fraudulent impressions that are filtered by verification vendors but counted by ad servers
- Privacy Regulations: Consent management platforms blocking tags for non-consenting users
- Cross-Domain Tracking Failures: Cookies not passing between domains
- Click vs. Click-Through: Some platforms count clicks at different points in the redirect chain
• Impressions: 5-15% discrepancy is typical between ad server and SSP
• Clicks: 10-20% discrepancy due to bots and click fraud
• Conversions: 20-30% discrepancy common due to lookback windows, attribution models, and tracking failures
Best Practice: Use a single source of truth (usually the advertiser's ad server) for billing and performance reporting.
🔮 The Future of Ad Tracking
The ad tracking landscape is undergoing radical transformation. Privacy regulations, browser changes, and consumer expectations are reshaping how we measure advertising effectiveness.
Key Trends
- Server-Side Tracking: Moving tracking from client-side (browser) to server-side to bypass ad blockers and improve accuracy. Examples: server-side GTM, conversion APIs.
- Aggregated Measurement: Moving from user-level tracking to aggregated, privacy-preserving reporting (Google's Attribution Reporting API, Meta's Aggregated Event Measurement).
- Data Clean Rooms: Secure environments where advertisers and publishers can measure performance without sharing raw user data.
- Universal IDs: Consented, deterministic identifiers replacing third-party cookies for cross-site tracking.
- Privacy Sandbox APIs: Google's suite of privacy-preserving measurement APIs (Attribution Reporting, Topics, FLEDGE).
- Third-party cookies are being deprecated (Chrome by end of 2025)
- iOS ATT framework limits IDFA access (20-30% opt-in rates)
- Privacy regulations (GDPR, CCPA) require consent for tracking
- Ad blockers and browser privacy features are growing
- Server-side and aggregated measurement are becoming standard
📚 Quick Reference: Tracking Essentials
Ad tag request; server-side or client-side; viewability standards
Redirect chain; click trackers; macros; 302 redirects
Pixel fires; cookie matching; attribution models; lookback windows
First-party vs third-party; cookie syncing; deprecation timeline
Central tracking hub; impression counting; click redirects; conversion attribution
Mobile attribution; device IDs; install postbacks; SKAdNetwork
${AUCTION_ID}, ${AUCTION_PRICE}, ${CLICK_URL} — dynamic value substitution
5-15% impressions; 10-20% clicks; 20-30% conversions — typical ranges