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

# Events & Tracking

> AdXensor automatically tracks four event types with no tracking code required — the SDK handles everything once initialized.

AdXensor tracks four event types automatically. You do not need to write any tracking code — the SDK handles everything once initialized.

## Tracked events

| Event          | Trigger                                      | Deduplication         |
| -------------- | -------------------------------------------- | --------------------- |
| **pageview**   | Page loads (once per `adx.init()` call)      | Once per page load    |
| **impression** | Ad creative is rendered in the DOM           | Once per ad × session |
| **view**       | Ad is ≥ 50% visible for ≥ 1 second (IAB MRC) | Once per ad × session |
| **click**      | Visitor clicks on the ad                     | 500 ms debounce       |

## How events are sent

All events use `navigator.sendBeacon` — a non-blocking, fire-and-forget transport that survives page unload. The SDK falls back to `fetch` with `keepalive: true` when `sendBeacon` is unavailable.

Events are sent to: `POST https://core.adxensor.com/v1/events/{type}`

## Event payload fields

Every event includes these base fields:

| Field         | Description                                    |
| ------------- | ---------------------------------------------- |
| `siteId`      | Your publisher Site ID                         |
| `sessionId`   | Random session ID (stored in `sessionStorage`) |
| `url`         | Current page URL                               |
| `device`      | `mobile` \| `tablet` \| `desktop`              |
| `language`    | 2-char ISO 639-1 code (e.g. `fr`, `en`)        |
| `screenWidth` | Viewport width in pixels                       |
| `ts`          | Unix timestamp (milliseconds)                  |

Country, OS, and browser are resolved **server-side** from the IP and User-Agent — no client-side fingerprinting.

## Session deduplication

Impressions and views are deduplicated within a browser session using `sessionStorage`. Each ad is recorded at most once per session, even if the user visits the same page multiple times in the same tab.

The deduplication key is stored in `sessionStorage` under `_adx_fired`.

## Manual event firing (advanced)

If you need to fire events manually (e.g. for a custom ad renderer), you can use the lower-level `Tracker` API:

```typescript theme={null}
import { AdXensorApi, Tracker, getSessionId } from '@adxensor/publisher-sdk';

const api = new AdXensorApi('https://core.adxensor.com/v1');
const sessionId = getSessionId();
const tracker = new Tracker(api, 'pub-XXXXXXXX', sessionId);

// Fire events manually
tracker.pageview();
tracker.impression('adId-123', 'header-banner', 'impressionToken');
tracker.view('adId-123', 'header-banner');
tracker.click('adId-123', 'header-banner', 'clickToken');
```

## Viewing stats in the dashboard

Events are processed in near-real-time. You can view aggregate impressions, views, and clicks under:

**Publisher Dashboard → My Sites → \[Your Site] → Statistics**
