Skip to Content

Attribution

Install attribution happens automatically on the first page load.

How It Works

  1. SDK collects device info (screen resolution, timezone, language, platform)
  2. Sends POST /api/v1/installs with the API key
  3. The server generates a fingerprint from device info + IP + User-Agent
  4. The attribution engine matches against stored ad clicks using a waterfall:
    • Device ID match — deterministic, 100% confidence
    • Fingerprint match — probabilistic, 60%+ confidence required
    • Organic — no matching click found
  5. The result is cached in localStorage and accessible via getAttribution()

Reading Attribution

import { getAttribution } from '@attributehq/web-sdk' const attribution = getAttribution() if (attribution && !attribution.isOrganic) { console.log('Attributed to:', attribution.mediaSource) console.log('Campaign:', attribution.campaignId) console.log('Confidence:', attribution.confidence + '%') }

Attribution Result

interface AttributionResult { matchType: 'device_id' | 'fingerprint' | 'organic' confidence: number // 0-100 mediaSource: string | null // e.g. 'facebook', 'google' campaignId: string | null // e.g. 'summer_promo_2025' isOrganic: boolean attributedTouchTime: number | null // Unix ms of the ad click }
FieldDescription
matchTypeHow the install was attributed
confidence100 for deterministic (device ID), 0-100 for probabilistic (fingerprint)
mediaSourceAd network identifier from the click URL pid parameter
campaignIdCampaign identifier from the click URL c parameter
isOrganictrue if no matching click found
attributedTouchTimeTimestamp of the original ad click (null for organic)

Attribution Window

The attribution engine looks for matching clicks within a 7-day window. Clicks older than 7 days are ignored and automatically cleaned up via DynamoDB TTL.

Click-to-Install Time Validation

Installs that occur within 10 seconds of a click are flagged as potentially fraudulent and rejected. This prevents click injection attacks.

Re-Attribution

Once an install is attributed, the result is cached in localStorage (__ahq_attribution). The SDK does not re-attribute on subsequent visits. To reset attribution (e.g., for testing), clear the __ahq_installed and __ahq_attribution keys from localStorage.