This guide shows you how to add Heyo to any HTML website. Perfect for static sites, landing pages, and simple projects.
Add this script tag before the closing </head> tag in your HTML:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>My Website</title>
<!-- Add Heyo here -->
<script src="https://heyo.so/embed/script" defer data-project-id="YOUR_PROJECT_ID"></script>
</head>
<body>
<!-- Your content -->
</body>
</html>
That's it! The chat widget will now appear on your page.
For multi-page sites, add the script to each HTML file, or create a shared header file:
Create header.html:
<script src="https://heyo.so/embed/script" defer data-project-id="YOUR_PROJECT_ID"></script>
Then include it in each page (using server-side includes, PHP, or your templating system).
Create heyo.js:
(function() {
const script = document.createElement('script');
script.src = 'https://heyo.so/embed/script';
script.defer = true;
script.setAttribute('data-project-id', 'YOUR_PROJECT_ID');
document.head.appendChild(script);
})();
Include in your HTML:
<script src="/js/heyo.js"></script>
Create a custom button to open the chat:
<button onclick="window.HEYO.show()">Chat with us</button>
<style>
button {
padding: 12px 24px;
background: #6366f1;
color: white;
border: none;
border-radius: 8px;
cursor: pointer;
font-size: 16px;
}
button:hover {
background: #4f46e5;
}
</style>
If using a custom button:
<style>
#heyo-widget-button {
display: none !important;
}
</style>
If you have user information (from a form or localStorage):
<script>
window.addEventListener('load', function() {
// Get user data from wherever you store it
const userName = localStorage.getItem('userName');
const userEmail = localStorage.getItem('userEmail');
if (window.HEYO && userName && userEmail) {
window.HEYO.init({
projectId: 'YOUR_PROJECT_ID',
user: {
name: userName,
email: userEmail
}
});
}
});
</script>
<script>
window.addEventListener('load', function() {
const currentPage = window.location.pathname;
// Hide on thank you page
if (currentPage.includes('thank-you.html')) {
window.HEYO?.hide();
}
// Only show on contact page
if (currentPage.includes('contact.html')) {
window.HEYO?.show();
}
});
</script>
Capture form data and pass to chat:
<form id="contactForm">
<input type="text" id="name" placeholder="Name" required>
<input type="email" id="email" placeholder="Email" required>
<button type="submit">Submit</button>
</form>
<script>
document.getElementById('contactForm').addEventListener('submit', function(e) {
e.preventDefault();
const name = document.getElementById('name').value;
const email = document.getElementById('email').value;
// Initialize Heyo with user data
if (window.HEYO) {
window.HEYO.init({
projectId: 'YOUR_PROJECT_ID',
user: { name, email }
});
// Open chat automatically
window.HEYO.show();
}
});
</script>
Create a custom sticky button:
<button id="chatButton" onclick="window.HEYO?.show()">
💬 Need Help?
</button>
<style>
#chatButton {
position: fixed;
bottom: 20px;
right: 20px;
padding: 12px 24px;
background: #6366f1;
color: white;
border: none;
border-radius: 50px;
cursor: pointer;
font-size: 16px;
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
z-index: 9999;
}
#chatButton:hover {
background: #4f46e5;
transform: translateY(-2px);
}
/* Hide default Heyo button */
#heyo-widget-button {
display: none !important;
}
</style>
In your _includes/head.html:
<script src="https://heyo.so/embed/script" defer data-project-id="{{ site.heyo_project_id }}"></script>
In _config.yml:
heyo_project_id: YOUR_PROJECT_ID
In your layouts/partials/head.html:
<script src="https://heyo.so/embed/script" defer data-project-id="{{ .Site.Params.heyoProjectId }}"></script>
In config.toml:
[params]
heyoProjectId = "YOUR_PROJECT_ID"
In your _includes/head.njk:
<script src="https://heyo.so/embed/script" defer data-project-id="{{ heyo.projectId }}"></script>
Heyo works perfectly with GitHub Pages:
No server-side code needed!
Load Heyo only after page load:
<script>
window.addEventListener('load', function() {
const script = document.createElement('script');
script.src = 'https://heyo.so/embed/script';
script.defer = true;
script.setAttribute('data-project-id', 'YOUR_PROJECT_ID');
document.head.appendChild(script);
});
</script>
Load when user scrolls:
<script>
let loaded = false;
function loadHeyo() {
if (!loaded) {
const script = document.createElement('script');
script.src = 'https://heyo.so/embed/script';
script.defer = true;
script.setAttribute('data-project-id', 'YOUR_PROJECT_ID');
document.head.appendChild(script);
loaded = true;
}
}
window.addEventListener('scroll', loadHeyo, { once: true });
// Also load after 5 seconds if no scroll
setTimeout(loadHeyo, 5000);
</script>
Control widget appearance on mobile:
<style>
@media (max-width: 768px) {
#heyo-widget-button {
bottom: 10px !important;
right: 10px !important;
width: 56px !important;
height: 56px !important;
}
}
</style>
<head> with defer attribute<meta name="viewport" content="width=device-width, initial-scale=1.0">