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

# Affiliate activation detection

> Specific instructions to use affiliate activation detection.

Sleek’s Web Extension SDK can detect affiliate activations in a browser tab and emit events when such activity is observed. These events help you track engagement, trigger UI changes, or log activity for analytics purposes.

<Warning>
  This document assumes that you have already integrated the Sleek web extension SDK into your
  extension. If you haven't, please refer to the [Web Extension SDK integration
  guide](/web-ext-sdk-reference/introduction).
</Warning>

## Overview

Affiliate activations are detected when the user visits or navigates to a URL that contains affiliate tracking parameters. When this happens, the web extension SDK emits an `AFFILIATE_ACTIVATION_DETECTED` event with details.

You can listen to this event using `registerEventListener()`.

## Usage

<CodeGroup>
  ```typescript TypeScript theme={null}
  import { getWebExtSdk } from "@sleek/web-ext-sdk";

  getWebExtSdk().registerEventListener((event, tabDetails) => {
    if (event.type === "AFFILIATE_ACTIVATION_DETECTED") {
      console.log("Affiliate detected", event.data, tabDetails);
    }
  });
  ```
</CodeGroup>

### Event Payload

<CodeGroup>
  ```typescript TypeScript theme={null}
  interface AffiliateActivationDetectedEvent {
    type: "AFFILIATE_ACTIVATION_DETECTED";
    data: {
      detectedUrl: string;
      detectedUrlCapturedOn: number; // Unix timestamp
      finalUrl: string;
      finalUrlCapturedOn: number; // Unix timestamp
    };
  }
  ```
</CodeGroup>

The event contains:

* `detectedUrl`: The affiliate-tracked URL
* `detectedUrlCapturedOn`: Timestamp when affiliate URL was detected
* `finalUrl`: Destination URL after redirection
* `finalUrlCapturedOn`: Timestamp when final URL was confirmed
