Attribution
Install attribution happens automatically on the first page load.
How It Works
- SDK collects device info (screen resolution, timezone, language, platform)
- Sends
POST /api/v1/installswith the API key - The server generates a fingerprint from device info + IP + User-Agent
- 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
- 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
}| Field | Description |
|---|---|
matchType | How the install was attributed |
confidence | 100 for deterministic (device ID), 0-100 for probabilistic (fingerprint) |
mediaSource | Ad network identifier from the click URL pid parameter |
campaignId | Campaign identifier from the click URL c parameter |
isOrganic | true if no matching click found |
attributedTouchTime | Timestamp 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.