Customer Support

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.

1

Get your write key

Each client account has its own write key. Log in to your account and go to:

Log in to your account›Configurations›SDK Keys tab
NOTE

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

2

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.

index.html — paste before </head>
<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>
REPLACE

YOUR_WRITE_KEY is the only value specific to your site — everything else in the snippet stays the same for all accounts.

2a

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.

2b

Optional data attributes

Add these to the same <script> tag to control SDK behaviour without writing JavaScript:

AttributePurpose
data-write-keyRequired — 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-cookieAuto-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', …).
2c

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.

SetupWhat visitors see
Server flag on + data-support-widget="true"The launcher and chat panel appear.
Server flag on, attribute missingNothing 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.
DELAY

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

3

Verify

Confirm the SDK loaded and your write key is being picked up.

  1. 1Open your site and open DevTools → Console.
  2. 2Type window.campaign and press Enter — you should see the SDK object, not undefined.
  3. 3In the Network tab, confirm a request to config.axilrate.com/sdk/campaign.min.js returns 200.
NEXT

Once live, configure the widget's behaviour — bot mode, handoff rules, business hours, and appearance — from the Customer Support settings in your account.

Campaign SDK — Chat Widgetcampaign.min.js