> ## 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.

# Configuration

> Configure the Everflow SDK for cross-subdomain tracking and organic fallback attribution.

Use `EF.configure()` to customize SDK behavior before calling any tracking methods. This is required when you need cross-subdomain cookie attribution or organic fallback tracking.

```javascript theme={null}
EF.configure({
  tld: "your-store.com",
  organic: {
    offer_id: 1,
    affiliate_id: 1
  }
});
```

Call `EF.configure()` **before** any `EF.click()`, `EF.conversion()`, or `EF.impression()` calls.

## Cross-subdomain tracking (tld)

By default, the SDK stores first-party cookies on the current subdomain. If a user clicks on `shop.your-store.com` but converts on `checkout.your-store.com`, the SDK cannot read the cookie across subdomains.

Set the `tld` option to store cookies at the top-level domain so all subdomains can access them:

```javascript theme={null}
EF.configure({ tld: "your-store.com" });
```

This ensures that a click recorded on any subdomain (e.g., `shop.your-store.com`, `www.your-store.com`) is accessible when the conversion fires on a different subdomain (e.g., `checkout.your-store.com`).

<Warning>
  Always use the fully qualified subdomain when loading pages. Use `www.your-store.com` instead of `your-store.com` to avoid cookie scoping issues.
</Warning>

### Example

```html theme={null}
<!-- On shop.your-store.com -->
<script src="https://www.your-tracking-domain.com/scripts/main.js"></script>
<script>
  EF.configure({ tld: "your-store.com" });

  // Click is recorded and cookie is stored at .your-store.com
  EF.click({
    offer_id: EF.urlParameter('oid'),
    affiliate_id: EF.urlParameter('affid')
  });
</script>
```

```html theme={null}
<!-- On checkout.your-store.com -->
<script src="https://www.your-tracking-domain.com/scripts/main.js"></script>
<script>
  EF.configure({ tld: "your-store.com" });

  // Conversion reads the cookie from .your-store.com
  EF.conversion({
    offer_id: 5,
    amount: 49.99
  });
</script>
```

## Organic tracking

If your tracking URLs don't always include `offer_id` and `affiliate_id` parameters, you can set fallback defaults using the `organic` option. When a user lands on your page without the expected URL parameters, the SDK uses these defaults instead of abandoning the tracking event.

```javascript theme={null}
EF.configure({
  organic: {
    offer_id: 1,
    affiliate_id: 1
  }
});
```

### How it works

1. User visits `your-store.com/?oid=5&affid=10` — SDK uses `offer_id: 5`, `affiliate_id: 10` from the URL
2. User visits `your-store.com/` (no parameters) — SDK falls back to `offer_id: 1`, `affiliate_id: 1` from the organic config

This is useful for:

* Landing pages that may receive both paid and organic traffic
* Pages where tracking parameters are sometimes stripped by redirects or intermediaries
* Ensuring conversions are never lost due to missing URL parameters

### Example

```html theme={null}
<script src="https://www.your-tracking-domain.com/scripts/main.js"></script>
<script>
  EF.configure({
    organic: {
      offer_id: 1,
      affiliate_id: 1
    }
  });

  // Uses URL params if present, otherwise falls back to organic defaults
  EF.click({
    offer_id: EF.urlParameter('oid'),
    affiliate_id: EF.urlParameter('affid')
  });
</script>
```

## Multi-account tracking (tracking\_domain)

If you work with multiple Everflow accounts, you can specify the `tracking_domain` directly on individual tracking calls to route events to the correct account:

```javascript theme={null}
EF.click({
  offer_id: 5,
  affiliate_id: 10,
  tracking_domain: "www.other-tracking-domain.com"
});
```

This overrides the default tracking domain set by the SDK script tag. You can use this on `EF.click()`, `EF.conversion()`, and `EF.impression()` calls.

<Warning>
  `tracking_domain` must always be a fully qualified subdomain. Apex domains are considered invalid and will cause the call to fail silently. Use `tracking_domain: "www.domain.com"`, **not** `tracking_domain: "domain.com"`.
</Warning>

### Routing different URL parameters to different accounts

Multi-tenant setups often need to read different query string parameters for each account from the same landing page. For example, a URL like `https://landing-page.com?oid=1&affid=2&offer=10&affiliate=17` can feed two separate accounts:

```html theme={null}
<script src="https://www.tracking-domain-a.com/scripts/main.js"></script>
<script>
  EF.click({
    tracking_domain: "www.tracking-domain-a.com",
    offer_id: EF.urlParameter('oid'),
    affiliate_id: EF.urlParameter('affid')
  });
  EF.click({
    tracking_domain: "www.tracking-domain-b.com",
    offer_id: EF.urlParameter('offer'),
    affiliate_id: EF.urlParameter('affiliate')
  });
</script>
```

<Note>
  Multi-tenant attribution has inherent challenges because the SDK relies on browser cookies to store transaction IDs. When two accounts use the same offer ID on the same page, a little custom attribution logic (using `EF.getTransactionId()` / `EF.getAdvertiserTransactionId()`) is typically required to match conversions to the correct click.
</Note>

## Combining options

All configuration options can be combined:

```javascript theme={null}
EF.configure({
  tld: "your-store.com",
  organic: {
    offer_id: 1,
    affiliate_id: 1
  }
});
```

## Options reference

| Option                 | Type     | Description                                                               |
| ---------------------- | -------- | ------------------------------------------------------------------------- |
| `tld`                  | `string` | Top-level domain for cookie storage. Enables cross-subdomain attribution. |
| `organic.offer_id`     | `number` | Fallback offer ID when URL parameters are missing.                        |
| `organic.affiliate_id` | `number` | Fallback affiliate ID when URL parameters are missing.                    |
