> ## Documentation Index
> Fetch the complete documentation index at: https://docs.datalyr.com/llms.txt
> Use this file to discover all available pages before exploring further.

# How Attribution Works

> Track clicks, conversions, and revenue back to the source with hybrid attribution

DATALYR uses hybrid attribution to connect every conversion back to the ad that drove it.

## What You'll Learn

* How hybrid attribution tracks ad performance
* Platform-specific click IDs and attribution windows
* Cross-device visitor linking
* Source and medium detection

## Use Cases

**E-commerce Attribution**
Track Shopify purchases back to Meta or Google ads. Measure true ROAS including cross-device conversions.

**SaaS Conversion Tracking**
Connect trial signups to the original ad click, even if they convert days later on a different device.

**Agency Reporting**
Show clients exactly which campaigns drove revenue. Attribution survives across multiple sessions.

**Lead Generation**
Attribute form submissions to campaigns even when users research first and convert later.

**Multi-Channel Marketing**
Understand which channels work together. See the full journey from first click to conversion.

## Attribution Strategy

DATALYR uses a two-step hybrid approach:

**Session-First Attribution**
When a conversion happens, DATALYR first checks if there was a click ID in the same session. This captures immediate conversions from the same visit.

**First-Click Fallback**
If no session attribution exists, DATALYR looks for the first click within the attribution window. This ensures credit goes to the original ad that brought the visitor, not just the most recent one.

## Supported Platforms

DATALYR tracks click IDs from all major ad platforms:

**Meta (Facebook/Instagram)**

* Click ID: `fbclid`
* Browser ID: `_fbp`
* Click cookie: `_fbc`
* Attribution window: 7 days click, 1 day view

**Google Ads**

* Click ID: `gclid`, `gbraid` (iOS), `wbraid` (web)
* Attribution window: 90 days click, 1 day view

**TikTok**

* Click ID: `ttclid`
* Browser ID: `_ttp`
* Attribution window: 28 days click, 1 day view

**Other Platforms**

* Microsoft/Bing: `msclkid`
* Twitter/X: `twclid`
* LinkedIn: `li_fat_id`
* Snapchat: `sclid`
* Pinterest: `epik`
* Reddit: `rdt_cid`

## UTM Parameters

DATALYR automatically captures and stores UTM parameters:

* `utm_source` - Traffic source (google, facebook, newsletter)
* `utm_medium` - Marketing medium (cpc, email, social)
* `utm_campaign` - Campaign name
* `utm_term` - Paid search keywords
* `utm_content` - Ad variation

**Automatic Source Detection**
If UTM parameters aren't present, DATALYR determines the source from:

1. Click IDs (fbclid → facebook, gclid → google)
2. Referrer domain (twitter.com → twitter)
3. Search engines (google.com → google)
4. Direct traffic when no referrer exists

## Cross-Device Tracking

When a visitor identifies (signs up or logs in), DATALYR links their anonymous sessions together.

**How It Works**

1. Anonymous visitor clicks Meta ad (session 1)
2. Visitor returns directly and signs up (session 2)
3. DATALYR links both sessions to the user
4. Conversion attributed back to original Meta click

This ensures attribution survives across devices and sessions.

## Attribution Windows

Different platforms use different attribution windows:

| Platform | Click Window | View Window |
| -------- | ------------ | ----------- |
| Meta     | 7 days       | 1 day       |
| Google   | 90 days      | 1 day       |
| TikTok   | 28 days      | 1 day       |
| Default  | 7 days       | 1 day       |

DATALYR respects these windows when attributing conversions to clicks.

## First Touch vs Last Touch

DATALYR tracks both:

**First Touch**
The very first time a visitor arrived with attribution data. Stored for 30 days.

**Last Touch**
The most recent visit with attribution data before conversion.

**Current Touch**
Attribution data from the current session.

All three are included in conversion events sent to ad platforms.

## Customer Journey

DATALYR maintains a complete journey of up to 30 touchpoints per visitor:

* Source/medium/campaign for each visit
* Session IDs to track behavior
* Timestamps to measure time to convert
* Days since first touch for cohort analysis

## What Gets Tracked

Every event includes:

**Click Attribution**

* Platform-specific click IDs
* Browser cookies (\_fbp, \_ttp, etc.)
* Days since attribution

**UTM Attribution**

* All 5 UTM parameters
* First touch UTM data
* Last touch UTM data

**Journey Data**

* Referrer and landing page
* Touchpoint count
* Cross-device linking status

## Privacy & Consent

DATALYR respects user privacy:

* Honors Do Not Track (DNT) when enabled
* Supports opt-out via `__dl_opt_out` cookie
* No tracking in private/incognito mode detection
* GDPR and CCPA compliant

## Next Steps

<CardGroup cols={2}>
  <Card title="Installation Overview" icon="download" href="/installation/overview">
    Add DATALYR to your website
  </Card>

  <Card title="Event Stream" icon="chart-line" href="/features/event-stream">
    See attribution data in real time
  </Card>

  <Card title="User Journeys" icon="route" href="/features/user-journeys">
    View complete visitor paths
  </Card>

  <Card title="Platform Integrations" icon="plug" href="/integrations/overview">
    Send conversions to ad platforms
  </Card>
</CardGroup>
