JavaScript SDK
Vanilla JavaScript version of the Kovio Chatbot Ad SDK. No React or framework dependencies required. Perfect for any web application, WordPress sites, or static HTML pages.Zero Dependencies: Pure vanilla JavaScript with no framework requirements. Works with any web application, including WordPress, static sites, and custom HTML pages.
Installation
1
Add the Script Tag
Add the script tag to your HTML page’s
<head> section:2
Create Container & Call Process
Add a container div and call the process function:
API Reference
window.kovio.process(keyword, theme, format, containerId)
Fetches and displays a contextual ad based on the provided keyword.
Comma-separated keywords to match ads (e.g.,
'technology,ai')Display theme -
'light' or 'dark'Ad format -
'standard' or 'small'ID of the container element where the ad will be displayed
Promise<void>
Examples
- Basic Usage
- Custom Container
- Dynamic Loading
Note: Replace
your-publisher-id with your actual publisher ID from the Kovio dashboard.Features
- ✅ No Dependencies - Pure vanilla JavaScript
- ✅ Auto-initialization - Automatically initializes when script loads
- ✅ Multiple Keywords - Comma-separated keyword support
- ✅ Themes - Light and dark theme support
- ✅ Formats - Standard and small ad formats
- ✅ Automatic Tracking - Impression and click tracking handled automatically
Ad Formats & Themes
- Standard Format
- Small Format
- Light Theme
Full ad with image, title, message, and button. Best for prominent placements.
Advanced Usage
Checking if SDK is Loaded
Checking if SDK is Loaded
Loading Multiple Ads
Loading Multiple Ads
WordPress Integration
WordPress Integration
Add to your theme’s Then in your template:
header.php:Best Practices
- Load script asynchronously - Use the
asyncattribute - Wait for SDK load - Use
window.addEventListener('load')before callingprocess() - Use relevant keywords - Match keywords to your page content
- Match your theme - Use
lightordarkto match your site’s design
Troubleshooting
Ad not showing?
Ad not showing?
- Check browser console for error messages
- Verify publisher ID - Make sure you’ve replaced
<YOUR_PUBLISHER_ID>oryour-publisher-idwith your actual publisher ID from the Kovio dashboard - Ensure container div exists with correct ID
- Wait for SDK to load before calling
process()
Script not loading?
Script not loading?
- Verify script URL is accessible
- Check that token parameter is included
- Ensure script has
asyncattribute
