Add your agent to a WordPress site

Install the Askocto chat widget on a WordPress site by adding the embed script to your theme or a code snippet tool, then test the widget.

Working draft. These docs are illustrative: names, endpoints and examples describe the intended behaviour and can change before launch.

Use this page to put your agent's chat bubble on a WordPress site. The widget is one script, so there is no plugin to build. You add the script to the footer of every page.

Before you start

  • An agent with the Website widget turned on. See Channels.
  • Permission to change your site's theme or add code to it.
  • The agent ID from Channels > Website widget > Install.

Add the script

  1. In Askocto, open the agent, select Channels > Website widget and choose Install.
  2. Copy the embed script.
<script src="https://cdn.askocto.co/embed.js" data-agent-id="agt_123" defer></script>
  1. In WordPress, add the script to the footer of every page. Use your theme's footer scripts setting, a code snippet tool of your choice, or your child theme's footer file.
  2. Clear any page cache your site uses.

You should see the chat bubble when you reload a page on your site.

Tip: Use a child theme or a snippet tool, not the parent theme, so a theme update does not remove the script.

Identify logged-in users

If visitors sign in to your site, tell the agent who they are. Your server must sign the user ID, so do this in PHP or another server code, not in the page. Pass the result to identify.

window.askocto.identify({
  userId: "usr_4821",
  userHash: "HMAC_FROM_YOUR_SERVER",
  email: "dana@example.com",
});

Steps and an example are in Identity verification.

Show the widget on selected pages

Add the script conditionally in your theme code, for example only on pages under /support, or use the iframe option to place the chat inside a page.

Test it

  1. Open the site in a private window and ask a question.
  2. Check Activity for the conversation.
  3. Compare with Test > Playground to confirm the same sources are used. See Playground.

Remove the widget

Delete the script from the footer and clear the cache.

Troubleshooting

  • No bubble appears. Check the page source for the script and clear your page cache.
  • The bubble appears twice. The script was added in two places. Keep one.
  • The script is stripped out. Some editors remove script tags from page content. Add it through the theme or snippet tool instead.

Something unclear or missing? Tell us and we will fix the page.