Beginner
How to install Hotjar tracking code on WordPress
Quick Answer
Installing Hotjar tracking code on WordPress requires copying your unique tracking script from Hotjar dashboard and adding it to your site's header. You can do this through WordPress plugins, theme editor, or manually adding the code to your theme's functions.php file.
Prerequisites
- Active Hotjar account
- WordPress admin access
- Basic understanding of WordPress dashboard
- Site with SSL certificate (HTTPS)
1
Log into your Hotjar account and locate tracking code
Sign in to your Hotjar dashboard at
hotjar.com. Navigate to Sites & Organizations in the left sidebar, then click on your website. Select Tracking Code from the site settings menu. Copy the complete tracking script that starts with <script> and ends with </script>.Tip
Make sure to copy the entire script including the opening and closing script tags.
2
Access your WordPress admin dashboard
Log into your WordPress site by going to
yoursite.com/wp-admin. Enter your admin credentials to access the dashboard. You'll need administrator privileges to install tracking codes.3
Choose your installation method
You have three main options:
- Plugin method: Install a header/footer plugin like "Insert Headers and Footers"
- Theme customizer: Use WordPress built-in customizer if your theme supports it
- Manual method: Edit your theme's header.php file directly
Tip
Avoid editing theme files directly if you're not comfortable with code, as mistakes can break your site.
4
Install and configure header plugin (recommended method)
Go to Plugins → Add New in your WordPress dashboard. Search for "Insert Headers and Footers" by WPBeginner. Click Install Now and then Activate. After activation, navigate to Settings → Insert Headers and Footers.
Tip
This plugin has over 2 million active installations and is regularly updated.
5
Add Hotjar tracking code to header section
In the "Insert Headers and Footers" settings page, paste your copied Hotjar tracking code into the Scripts in Header text box. Make sure the code is pasted exactly as copied from Hotjar, without any extra spaces or characters. Click Save to apply the changes.
Tip
The header section ensures Hotjar loads before your page content, providing better tracking accuracy.
6
Verify installation in Hotjar dashboard
Return to your Hotjar dashboard and go to the Tracking Code section. Click Verify Installation or refresh the page. Hotjar will automatically detect if the tracking code is properly installed. You should see a green checkmark and "Receiving Data" status within a few minutes.
Tip
It may take up to 10 minutes for Hotjar to detect the tracking code installation.
7
Test tracking functionality
Visit your website in a new browser tab or incognito window. Navigate through a few pages and perform some actions. Return to your Hotjar dashboard and check Recordings or Heatmaps sections to confirm data is being collected. You should see visitor activity within 15-30 minutes.
Tip
Use incognito mode or a different browser to ensure you're not excluded by any ad blockers or privacy settings.
Troubleshooting
Hotjar shows 'Not Receiving Data' status after installation
Wait up to 30 minutes for data to appear. If still not working, check that the tracking code is in the <head> section of your site, clear any caching plugins, and ensure your site has HTTPS enabled.
Tracking code disappears after theme updates
This happens when code is added directly to theme files. Switch to using a plugin like "Insert Headers and Footers" or add the code to a child theme's
functions.php file to prevent loss during updates.Site loading slowly after installing Hotjar
Ensure you're using the latest Hotjar tracking code which loads asynchronously. Check with your hosting provider about server performance and consider using a caching plugin to improve overall site speed.
WordPress editor shows 'Unable to communicate back with site' error
This can occur when adding tracking code incorrectly. Remove the Hotjar code temporarily, check for any syntax errors, and re-add it. If using the theme editor, ensure you have a backup of your original files.
Ready to get started with Hotjar?
Put this tutorial into practice. Visit Hotjar and follow the steps above.
Visit Hotjar →