Embedding the Chat Widget
Add your AI chat agent to your website with one line of code.
Getting Your Embed Code
- Go to Chat Widget > select your agent
- Click the Embed tab
- Copy the embed code
Basic Embed Code
<script
src="https://api.site2crm.io/api/public/chat-widget/widget.js"
data-widget-key="YOUR_WIDGET_KEY"
async>
</script>
Where to Add It
Add the code just before the closing </body> tag on your website.
WordPress
- Go to Appearance > Theme Editor > footer.php
- Or use a plugin like "Insert Headers and Footers"
Webflow
- Go to Project Settings > Custom Code > Footer Code
Squarespace
- Go to Settings > Advanced > Code Injection > Footer
Wix
- Go to Settings > Custom Code > Add Code to Body (end)
Shopify
- Go to Online Store > Themes > Edit Code > theme.liquid (before </body>)
HTML Site
- Add before the closing
</body>tag
Excluding Pages
You may not want the chat widget on every page. Use the data-exclude-paths attribute:
<script
src="https://api.site2crm.io/api/public/chat-widget/widget.js"
data-widget-key="YOUR_WIDGET_KEY"
data-exclude-paths="/login,/signup,/checkout,/admin/*"
async>
</script>
Pattern examples:
/login- Exact match for /login page/admin/*- Wildcard matches /admin/anything/app/*,/dashboard/*- Multiple patterns (comma-separated)
Hiding for Logged-In Users
If you want to hide the widget for authenticated users on your platform:
Option 1: JavaScript
// When user logs in
localStorage.setItem('site2crm_hide_chat', 'true');
// When user logs out
localStorage.removeItem('site2crm_hide_chat');
Option 2: Cookie
// When user logs in
document.cookie = 'site2crm_hide_chat=true; path=/';
// When user logs out
document.cookie = 'site2crm_hide_chat=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/';
The widget checks for both localStorage and cookies.
Testing Your Embed
- Add the code to your website
- Clear your browser cache
- Visit your website
- Chat bubble should appear
- Click to open and test a conversation
- Check that leads appear in your dashboard
Troubleshooting
Widget not appearing?
- Check browser console for errors
- Verify the widget key is correct
- Make sure the script isn't blocked by ad blockers
- Check you're not on an excluded path
Widget appearing where it shouldn't?
- Add the path to
data-exclude-paths - Set localStorage flag for authenticated users