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

# Everflow SDK

> Track clicks, conversions, and impressions client-side using the Everflow JavaScript SDK.

The Everflow JavaScript SDK enables client-side tracking directly on your website. It supports direct linking — tracking user activity without requiring a redirect through a tracking link. This is useful when third-party links or cookies cannot be used.

<Note>The JavaScript SDK is not optimized for Internet Explorer.</Note>

## Installation

### Via npm

```bash theme={null}
npm install @everflow/everflow-sdk
```

```javascript theme={null}
import EverflowSDK from "@everflow/everflow-sdk";

EverflowSDK.configure({ tracking_domain: "YOUR-TRACKING-DOMAIN.com" });
```

### Via script tag

Add the SDK script tag to every page where you want to track events. Replace `YOUR-TRACKING-DOMAIN.com` with your actual Everflow tracking domain:

```html theme={null}
<script type="text/javascript" src="https://www.YOUR-TRACKING-DOMAIN.com/scripts/main.js"></script>
```

The script exposes the global `EF` object with methods for click tracking, conversion tracking, and impression tracking.

<Card title="GitHub Repository" icon="github" href="https://github.com/everflow-io/everflow-sdk">
  View the source code, report issues, and contribute on GitHub.
</Card>

### Page load performance

If the SDK script slows down page load, you have a few options:

* **Load it last** — place the script tag just before the closing `</body>` tag so it doesn't block above-the-fold content.
* **Self-host the file** — download `main.js` and serve it from your own domain to avoid a third-party request. The served file already has your tracking domain baked in, so it works as-is — but it's a frozen snapshot that won't pick up SDK updates. For a maintainable build, install the [npm package](#via-npm) (`@everflow/everflow-sdk`) instead and set the tracking domain yourself with `EF.configure({ tracking_domain: '…' })`.
* **Load it deferred** — create the script element with `defer` and run your tracking from its `onload` handler, so it never blocks rendering:

```html theme={null}
<script type="text/javascript">
  var script = document.createElement('script');
  script.src = "https://www.YOUR-TRACKING-DOMAIN.com/scripts/main.js";
  script.defer = true;
  script.onload = function() {
    EF.click({
      offer_id: EF.urlParameter('oid'),
      affiliate_id: EF.urlParameter('affid')
    });
  };
  document.body.append(script);
</script>
```

See [Tracking Recipes](/sdk/recipes#cross-site-hidden-field-organic-cross-subdomain-async) for a full deferred-load example.

## Available Modules

<CardGroup cols={2}>
  <Card title="Configuration" icon="gear" href="/sdk/configuration">
    Set up cross-subdomain tracking and organic fallback attribution.
  </Card>

  <Card title="Click Tracking" icon="arrow-pointer" href="/sdk/click-tracking">
    Record clicks and generate transaction IDs for attribution.
  </Card>

  <Card title="Click Tracking Recipes" icon="clipboard" href="/sdk/recipes">
    Copy-paste templates for every supported landing page scenario.
  </Card>

  <Card title="Conversion Tracking" icon="circle-check" href="/sdk/conversion-tracking">
    Fire conversion events with amounts, event IDs, and custom parameters.
  </Card>

  <Card title="Impression Tracking" icon="eye" href="/sdk/impression-tracking">
    Log impression events for CPM-based offers.
  </Card>
</CardGroup>

## Helper Methods

### EF.urlParameter(paramName)

Extracts a query string parameter from the current page URL. Returns `null` if the parameter is not present.

```javascript theme={null}
// URL: https://example.com/?oid=5&affid=10
const offerId = EF.urlParameter('oid');       // "5"
const affiliateId = EF.urlParameter('affid'); // "10"
```

### EF.getTransactionId(offerId)

Returns the most recent transaction ID for a given offer. Returns an empty string if no transaction exists.

```javascript theme={null}
const txnId = EF.getTransactionId(5);
```

### EF.getAdvertiserTransactionId(advertiserId)

Returns the most recent transaction ID for a given advertiser, regardless of which offer generated it.

```javascript theme={null}
const txnId = EF.getAdvertiserTransactionId(2);
```
