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

# Web (JavaScript)

> Drop-in JavaScript SDK for web apps. Full demand eligibility, automatic tracking.

<Info>
  **Full demand eligibility.** This SDK runs in a real browser. All four demand tiers serve, and impression, engagement, and click tracking are automatic.
</Info>

## Install

Add the script tag before the closing body tag:

```html theme={null}
<script src="https://sdk.adgentek.ai/v1/adgentek.js?token=YOUR_PUBLISHER_TOKEN"></script>
```

## Configure

Set global configuration before the script tag loads. All fields are optional:

```html theme={null}
<script>
window.adgentekConfig = {
  userId: 'optional-stable-id',
  theme: {
    colorScheme: 'auto',
    accentColor: '#1B6EF8',
    maxWidth: '640px'
  }
};
</script>
```

## Register a placement

Call after each AI response with the conversational context for the turn:

```javascript theme={null}
adgentek.placement({
  query: userMessage,       // required: the user's message
  response: aiResponse,     // required: your AI's response
  target: '#ad-slot',       // optional: CSS selector or element; omit for auto-discovery
  turnId: 'turn-123'        // optional: pairs events across an SPA turn
});
```

The SDK decides whether to serve based on intent. Most turns serve nothing; that is by design.

## Verify

1. DevTools, Network tab: confirm the serve request and its response.
2. Trigger a commercial-intent turn and confirm the ad renders.
3. Confirm the impression pixel request fires from the page on render.

## Reference

| Field      | Type              | Required | Description                                  |
| ---------- | ----------------- | -------- | -------------------------------------------- |
| `query`    | string            | Yes      | The user's message for the turn              |
| `response` | string            | Yes      | Your AI's response for the turn              |
| `target`   | string or Element | No       | Where to render; auto-discovery when omitted |
| `turnId`   | string            | No       | Stable ID pairing events across a turn       |
