This guide shows you how to add Heyo to your WordPress website. No coding knowledge required.
<script src="https://heyo.so/embed/script" defer data-project-id="YOUR_PROJECT_ID"></script>
If you're comfortable editing theme files:
header.php</head> tag:<script src="https://heyo.so/embed/script" defer data-project-id="YOUR_PROJECT_ID"></script>
Add this code to your theme's functions.php:
function heyo_chat_widget() {
?>
<script src="https://heyo.so/embed/script" defer data-project-id="YOUR_PROJECT_ID"></script>
<?php
}
add_action('wp_head', 'heyo_chat_widget');
Heyo works perfectly with WooCommerce out of the box. Here are some tips:
function heyo_chat_widget() {
// Only show on WooCommerce pages
if (is_woocommerce() || is_cart() || is_checkout()) {
?>
<script src="https://heyo.so/embed/script" defer data-project-id="YOUR_PROJECT_ID"></script>
<?php
}
}
add_action('wp_head', 'heyo_chat_widget');
Pass logged-in customer data to Heyo:
function heyo_chat_widget() {
$current_user = wp_get_current_user();
?>
<script src="https://heyo.so/embed/script" defer data-project-id="YOUR_PROJECT_ID"></script>
<script>
window.addEventListener('load', function() {
if (window.HEYO) {
window.HEYO.init({
projectId: 'YOUR_PROJECT_ID',
user: {
name: '<?php echo esc_js($current_user->display_name); ?>',
email: '<?php echo esc_js($current_user->user_email); ?>'
}
});
}
});
</script>
<?php
}
add_action('wp_head', 'heyo_chat_widget');
Using WordPress conditional tags:
function heyo_chat_widget() {
// Don't show on thank you page
if (is_page('thank-you')) {
return;
}
// Don't show in admin
if (is_admin()) {
return;
}
?>
<script src="https://heyo.so/embed/script" defer data-project-id="YOUR_PROJECT_ID"></script>
<?php
}
add_action('wp_head', 'heyo_chat_widget');
function heyo_chat_widget() {
if (!is_user_logged_in()) {
?>
<script src="https://heyo.so/embed/script" defer data-project-id="YOUR_PROJECT_ID"></script>
<?php
}
}
add_action('wp_head', 'heyo_chat_widget');
Add a custom button anywhere in your theme:
<button onclick="window.HEYO?.show()">
Need Help? Chat with us!
</button>
Alternatively, use Elementor's Theme Builder to add it to your header template site-wide.
Add an HTML block to any page and paste the script code.
Heyo works with all major caching plugins:
The widget loads asynchronously and won't be affected by page caching.
For even better performance, load Heyo only when needed:
function heyo_lazy_load() {
?>
<script>
// Load chat when user scrolls or after 5 seconds
let loaded = false;
function loadChat() {
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', loadChat, { once: true });
setTimeout(loadChat, 5000);
</script>
<?php
}
add_action('wp_footer', 'heyo_lazy_load');
<head>, not <body>