Add the chat widget
No build step, no npm install — two script tags in your <head>and you're done. The first queues any calls made before the SDK loads; the second loads the SDK itself using your write key.
Get your write key
Each client account has its own write key. Log in to your account and go to:
SDK Keys tabUse the prod key (ax_prod_…) for your live site and the staging key (ax_stg_…) for development — they're prefixed so they're easy to tell apart.
Paste the snippet into your <head>
Copy the block below and paste it inside <head>, before the closing </head> tag. Replace YOUR_WRITE_KEY with the key from step 1.
<script> (function (w, d, s) { var q = []; function stub() { q.push(arguments); } stub.q = q; w.campaign = w.campaign || stub; })(window, document, 'script'); </script> <script async src="https://config.axilrate.com/sdk/campaign.min.js" data-write-key="YOUR_WRITE_KEY" data-support-widget="true" ></script>
YOUR_WRITE_KEY is the only value specific to your site — everything else in the snippet stays the same for all accounts.
What each piece does
The first <script> block is a synchronous stub that queues any campaign(…) calls made before the real script finishes loading — nothing is lost if your own code calls it higher up the page. The second loads the SDK itself with async, so it never blocks page render. data-write-key identifies which account it belongs to.
Optional data attributes
Add these to the same <script> tag to control SDK behaviour without writing JavaScript:
| Attribute | Purpose |
|---|---|
| data-write-key | Required — identifies your account. |
| data-support-widget="true" | Required to show the chat widget — it is off by default. It also needs the server-side flag to be on (see 2c). |
| data-user-id-cookie | Auto-identify a returning logged-in visitor from a cookie your login flow already sets. |
| data-webpush-prompt="off" | Never auto-show the web push opt-in prompt (it auto-shows by default). Tracking is unaffected. |
| data-webpush-prompt-audience="logged-in" | Only offer the web push prompt to visitors you've identified with campaign('identify', …). |
Turning the widget on and off from the server
The widget appears only when both are on: data-support-widget="true" in your snippet (your site opting in) and the Customer Support flag for your write key on the server. That lets the server flag be on for other reasons — for example to run WhatsApp support — without a chat widget appearing on a site that hasn't asked for one, and lets you switch the chat off from the server without editing your site.
| Setup | What visitors see |
|---|---|
Server flag on + data-support-widget="true" | The launcher and chat panel appear. |
| Server flag on, attribute missing | Nothing renders — the site hasn't opted in. |
| Server flag off (or unavailable) | Nothing renders — the widget isn't drawn and then hidden, it is simply never mounted. |
A change takes up to about 5 minutes to reach visitors (the answer is cached), and a page that's already open keeps its current state until it's reloaded. To take it off your site without touching the server flag, remove data-support-widget="true".
Verify
Confirm the SDK loaded and your write key is being picked up.
- 1Open your site and open DevTools → Console.
- 2Type
window.campaignand press Enter — you should see the SDK object, notundefined. - 3In the Network tab, confirm a request to
config.axilrate.com/sdk/campaign.min.jsreturns 200.
Once live, configure the widget's behaviour — bot mode, handoff rules, business hours, and appearance — from the Customer Support settings in your account.