# Click Tracking

> Install the Affitor tracker to capture affiliate clicks and store attribution cookies. Triggers on "add affiliate tracking", "install tracker", "click tracking".

- Skill: `affitor/click-tracking` (Agent Skill)
- Install (CLI): `npx skillmds@latest add affitor/click-tracking`
- Raw SKILL.md: https://api.skillmd.com/api/skills/affitor/click-tracking/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Coding & Dev Tools
- License: MIT
- Author: affitor (https://skillmd.com/u/affitor)
- Updated: 2026-09-17
- Page: https://skillmd.com/skills/affitor/click-tracking

---


# Click Tracking

Add the Affitor tracker to capture when visitors arrive via affiliate links (`?aff=PARTNER_CODE`).

## Script Tag (any site)

Add to `<head>` on every page:

```html
<script src="https://api.affitor.com/js/affitor-tracker.js"
  data-affitor-program-id="YOUR_PROGRAM_ID">
</script>
```

## npm SDK (React, Next.js, any JS/TS)

```bash
npm install @affitor/tracker
```

### React / Next.js

```tsx
import { AffitorProvider } from '@affitor/tracker/react';

export default function RootLayout({ children }) {
  return (
    <AffitorProvider programId="YOUR_PROGRAM_ID">
      {children}
    </AffitorProvider>
  );
}
```

### Any JS/TS

```ts
import { loadAffitor } from '@affitor/tracker';
const affitor = await loadAffitor('YOUR_PROGRAM_ID');
```

## What It Does

- Detects `?aff=` parameter in URL
- Stores `affitor_click_id` in a first-party cookie (60-day default)
- Creates customer-partner relationship for attribution
- Later signup and sale tracking use this cookie for linking

## Debug Mode

Set `data-affitor-debug="true"` (script) or `debug: true` (SDK) to see tracking events in browser console.

## Get Your Program ID

Run `npx affitor init` or find it in your Affitor dashboard under Settings.

