How to Install a Heatmap on Your Website
Installing a heatmap tool is one of the highest-impact optimizations you can make—and it's faster than you think. Most setups take under 15 minutes.
This guide walks you through three installation methods (script insertion, Google Tag Manager, platform plugins), plus specific instructions for Hotjar, Clarity, and Crazy Egg, with bonus sections for WordPress and Shopify.
Three Installation Methods
Before we get to specific tools, understand your installation options:
Method 1: Direct Script Installation (Easiest)
What it is: Copy-paste a JavaScript snippet into your website's HTML
Time required: 5-10 minutes
Best for: Static sites, custom builds, developers
Pros:
- Simplest method
- Immediate implementation
- No platform dependencies
- Full control
Cons:
- Requires HTML access
- Not ideal for large codebases
- Updates require manual changes
Steps:
- Get script from heatmap tool dashboard
- Add to
<head>or before closing</body>tag - Save and deploy
- Verify in dashboard within minutes
Method 2: Google Tag Manager (Most Flexible)
What it is: Deploy heatmap tracking through GTM instead of directly in code
Time required: 10-15 minutes
Best for: Teams using GTM, sites wanting tag management, complex deployments
Pros:
- Manage all tracking from one place
- No code changes needed
- Easy to enable/disable
- Audit trail of changes
Cons:
- Requires GTM setup
- Slight delay in tracking (GTM loads asynchronously)
- Additional dependency
Steps:
- Create new tag in GTM
- Select heatmap tool template
- Add account ID or script
- Set trigger to "All Pages"
- Publish GTM container
Method 3: Native Plugins (Platform-Specific)
What it is: Use built-in plugins for WordPress, Shopify, or other platforms
Time required: 2-5 minutes
Best for: WordPress sites, Shopify stores, non-technical users
Pros:
- Dead simple setup
- No coding required
- Automatic updates
- Best platform integration
Cons:
- Limited to supported platforms
- Less customization
- Plugin dependency
Steps:
- Search plugin marketplace for heatmap tool
- Install plugin
- Authenticate with heatmap account
- Activate
Installation Guide: Microsoft Clarity
Prerequisite
Free account at clarity.microsoft.com
Method 1: Direct Script Installation
Step 1: Get Your Tracking Script
- Log into Clarity dashboard
- Click "Projects" → Create new project (if needed)
- Go to "Settings" → "Installation"
- Copy the JavaScript snippet
The script looks like:
<script>
(function(c,l,a,r,i,t,y){
c[a]=c[a]||function(){(c[a].q=c[a].q||[]).push(arguments)};
t=l.createElement(r);t.async=1;t.src="https://www.clarity.ms/tag/"+i;
y=l.getElementsByTagName(r)[0];y.parentNode.insertBefore(t,y);
})(window, document, "clarity", "script", "YOUR_PROJECT_ID");
</script>
Step 2: Insert Script Into Your Website
For a typical Next.js or React app:
Add to your _app.tsx or _document.tsx:
useEffect(() => {
(function(c,l,a,r,i,t,y){
c[a]=c[a]||function(){(c[a].q=c[a].q||[]).push(arguments)};
t=l.createElement(r);t.async=1;t.src="https://www.clarity.ms/tag/"+i;
y=l.getElementsByTagName(r)[0];y.parentNode.insertBefore(t,y);
})(window, document, "clarity", "script", "YOUR_PROJECT_ID");
}, []);
For static HTML sites:
Add before closing </body>:
<script>
(function(c,l,a,r,i,t,y){
c[a]=c[a]||function(){(c[a].q=c[a].q||[]).push(arguments)};
t=l.createElement(r);t.async=1;t.src="https://www.clarity.ms/tag/"+i;
y=l.getElementsByTagName(r)[0];y.parentNode.insertBefore(t,y);
})(window, document, "clarity", "script", "YOUR_PROJECT_ID");
</script>
Step 3: Deploy and Verify
- Deploy your site changes
- Visit your website
- Return to Clarity dashboard
- Within 1-2 minutes, you should see "Project Status: Active"
Method 2: Google Tag Manager
Step 1: Create GTM Account and Container
- Go to google.com/tagmanager
- Click "Create Account"
- Enter account name and website URL
- Create container and install GTM script on your site
Step 2: Add Clarity to GTM
- Log into Google Tag Manager
- Select your container
- Click "Tags" → "New"
- Tag name: "Clarity Analytics"
- Choose tag type: "Custom HTML"
- Paste Clarity's script snippet into the HTML field:
<script>
(function(c,l,a,r,i,t,y){
c[a]=c[a]||function(){(c[a].q=c[a].q||[]).push(arguments)};
t=l.createElement(r);t.async=1;t.src="https://www.clarity.ms/tag/"+i;
y=l.getElementsByTagName(r)[0];y.parentNode.insertBefore(t,y);
})(window, document, "clarity", "script", "YOUR_PROJECT_ID");
</script>
Step 3: Set Trigger
- Under "Triggering," click "Trigger Configuration"
- Select "All Pages"
Step 4: Publish
- Click "Submit"
- Write a version description: "Add Clarity heatmaps"
- Click "Publish"
Clarity will track within 2-5 minutes.
Installation Guide: Hotjar
Prerequisite
Account at hotjar.com
Method 1: Direct Script Installation
Step 1: Get Your Hotjar Tracking Code
- Log into Hotjar
- Go to "Settings" → "Install Hotjar"
- Copy the Hotjar script:
<script>
window.hj=window.hj||function(){(hj.q=hj.q||[]).push(arguments)};
hj('identify',{userId:'123456'});
</script>
<script async src='https://static.hotjar.com/c/hotjar-XXXXXXX.js?sv=YOUR_VERSION'></script>
Step 2: Insert Into Your Website
For Next.js/React apps, add to _document.tsx:
<Head>
<script>
{`window.hj=window.hj||function(){(hj.q=hj.q||[]).push(arguments)};
hj('identify',{userId:'123456'});`}
</script>
<script async src='https://static.hotjar.com/c/hotjar-XXXXXXX.js?sv=YOUR_VERSION'></script>
</Head>
For WordPress/HTML sites:
Add to site header (Theme Settings → Custom Code, or via child theme):
<script>
window.hj=window.hj||function(){(hj.q=hj.q||[]).push(arguments)};
hj('identify',{userId:'123456'});
</script>
<script async src='https://static.hotjar.com/c/hotjar-XXXXXXX.js?sv=YOUR_VERSION'></script>
Step 3: Verify
- Save and deploy changes
- Visit your website
- Open browser console (F12)
- Type
hj— you should see the Hotjar object - Hotjar dashboard should show "Hotjar is installed"
Method 2: WordPress Plugin
Step 1: Install Plugin
- In WordPress admin, go to "Plugins" → "Add New"
- Search for "Hotjar"
- Install official Hotjar plugin by Hotjar
- Activate
Step 2: Connect Account
- Go to "Hotjar" in WordPress left menu
- Click "Settings"
- Enter your Hotjar Site ID (from Hotjar dashboard → Settings → Install Hotjar)
- Save
Tracking begins immediately.
Method 3: Google Tag Manager
- Create "Custom HTML" tag in GTM
- Paste Hotjar script
- Set trigger to "All Pages"
- Publish
Same process as Clarity GTM implementation above.
Installation Guide: Crazy Egg
Prerequisite
Account at crazyegg.com
Method 1: Direct Script Installation
Step 1: Get Tracking Code
- Log into Crazy Egg
- Click "Settings" → "Install"
- Copy the Crazy Egg script:
<script type='text/javascript'>
setTimeout(function(){var a=document.createElement("script");
var b=document.getElementsByTagName("script")[0];
a.src=document.location.protocol+"//script.crazyegg.com/pages/scripts/YOUR_ID.js?acc=YOUR_ACCOUNT_ID";
a.async=true;a.type="text/javascript";b.parentNode.insertBefore(a,b)}, delay);
</script>
Step 2: Insert Into Your Website
For custom HTML sites, add before closing </body>:
<script type='text/javascript'>
setTimeout(function(){var a=document.createElement("script");
var b=document.getElementsByTagName("script")[0];
a.src=document.location.protocol+"//script.crazyegg.com/pages/scripts/YOUR_ID.js?acc=YOUR_ACCOUNT_ID";
a.async=true;a.type="text/javascript";b.parentNode.insertBefore(a,b)}, 2000);
</script>
For Next.js apps, add to _document.tsx:
<body>
{/* ... */}
<script type='text/javascript'>
{`setTimeout(function(){var a=document.createElement("script");
var b=document.getElementsByTagName("script")[0];
a.src=document.location.protocol+"//script.crazyegg.com/pages/scripts/YOUR_ID.js?acc=YOUR_ACCOUNT_ID";
a.async=true;a.type="text/javascript";b.parentNode.insertBefore(a,b)}, 2000);`}
</script>
</body>
Step 3: Verify
- Deploy changes
- Visit your website
- Wait 5-10 minutes for initial data collection
- Check Crazy Egg dashboard for heatmaps
WordPress-Specific Installation
Option 1: Using Native WordPress Plugin
Best plugins:
- Hotjar (official)
- Clarity (Microsoft's official plugin)
- MonsterInsights (supports heatmap integrations)
Installation:
- WordPress Admin → Plugins → Add New
- Search for heatmap tool name
- Click Install, then Activate
- Add your Site ID in plugin settings
- Tracking begins immediately
Option 2: Manual Installation (Any Heatmap Tool)
If your preferred tool lacks a WordPress plugin:
Step 1: Edit Your Theme
- WordPress Admin → Appearance → Theme File Editor
- Look for
header.phporfunctions.php
Step 2: Add Tracking Script
For header.php, add before closing </head>:
<head>
<!-- ... existing code ... -->
<!-- Heatmap Script -->
<script>
[YOUR_HEATMAP_SCRIPT_HERE]
</script>
</head>
For functions.php, add heatmap via hook:
add_action('wp_head', 'add_heatmap_script');
function add_heatmap_script() {
?>
<script>
[YOUR_HEATMAP_SCRIPT_HERE]
</script>
<?php
}
Step 3: Save
WordPress will validate syntax automatically.
Option 3: Using a Tag Manager Plugin
Instead of editing theme files directly:
- Install "Google Tag Manager for WordPress" plugin
- Add your GTM ID
- Deploy your heatmap script via GTM (see GTM section)
This keeps all tracking centralized and doesn't require theme editing.
Shopify-Specific Installation
Option 1: Using Shopify Apps
Many heatmap tools offer official Shopify apps:
Hotjar:
- Visit Shopify App Store
- Search "Hotjar"
- Click "Add app"
- Authorize and install
- Tracking begins immediately
Crazy Egg:
- Search "Crazy Egg" in Shopify App Store
- Install and authorize
- Add your Site ID in app settings
Step: Always check if your heatmap tool has an official Shopify app first—it's the simplest option.
Option 2: Manual Installation via Theme Code
If your tool lacks a Shopify app:
Step 1: Access Theme Editor
- Shopify Admin → Sales channels → Online Store → Themes
- Click your active theme
- Click "Edit code"
Step 2: Locate Theme Files
Look for theme.liquid (main template file).
Step 3: Add Heatmap Script
In theme.liquid, paste your heatmap script in the <head> section:
<head>
<!-- ... existing code ... -->
<script>
[YOUR_HEATMAP_SCRIPT_HERE]
</script>
</head>
Step 4: Save
Click "Save" in the top right. Changes deploy immediately.
Option 3: Using Shopify's Script Editor (Legacy)
Note: Shopify is phasing out Script Editor in favor of Checkout Extensibility, but for tracking scripts:
- Shopify Admin → Settings → Apps and integrations → Script Editor
- Click "Create script"
- Choose "Sales channel" or "Checkout" script type
- Paste your heatmap code
- Save
Not all heatmap tools work perfectly with Script Editor, so manual theme editing is more reliable.
Verifying Installation
Universal Verification Steps
After installing your heatmap code, verify it's working:
Step 1: Check Browser Console
- Visit your website
- Press F12 (Windows) or Cmd+Option+I (Mac)
- Click "Console" tab
- Check for errors (red messages)
- Look for heatmap confirmation (varies by tool):
- Clarity: Look for a message mentioning your project ID
- Hotjar: Type
hjand press Enter—you should see a JavaScript object - Crazy Egg: Type
CE_SNAPSHOT_DATAand press Enter—should return an object
Step 2: Check Tool Dashboard
- Log into your heatmap account
- Go to your project/site
- Check for "Status: Active" or similar indicator
- Within 5-30 minutes, you should see:
- Green checkmark indicating tracking is live
- Session count increasing
- First heatmap data appearing
Step 3: Network Tab Verification
For advanced users:
- Open browser DevTools → Network tab
- Refresh page
- Filter for your heatmap tool's domain:
- Clarity:
clarity.ms - Hotjar:
hotjar.com - Crazy Egg:
crazyegg.com
- Clarity:
- You should see successful (200) requests
Troubleshooting Verification Failures
Script not loading?
- Check console for syntax errors
- Verify account ID/Site ID is correct
- Ensure script isn't being blocked by privacy extensions
- Check that script placement is correct (not inside conditional blocks)
Tool dashboard shows inactive?
- Wait 5-10 minutes—sometimes dashboards lag
- Refresh browser or clear cache
- Verify you're on the correct website in tool settings
- Check that script tag uses exact ID from dashboard
Heatmap shows no data?
- Verify tracking is active first (see above steps)
- Wait 1-2 hours for initial data collection
- Generate traffic (visit multiple pages yourself)
- Check if filters are applied (e.g., device, date range filters)
Common Installation Issues and Solutions
Issue 1: Script Already Installed (Duplicate Tracking)
Problem: You install the heatmap script but later discover it was already installed by someone else.
Solution:
- Check your theme code carefully for existing scripts
- Search your codebase for the tool name
- Remove one copy—duplicate scripts waste bandwidth
- Verify with browser console that script still loads
Issue 2: Script Conflicts
Problem: Multiple tracking scripts cause page slowdown or errors.
Solution:
- Use Google Tag Manager instead of multiple direct scripts
- Combine related tracking under one platform
- Use async loading (already default in most heatmap tools)
- Test page speed before and after installation
Issue 3: Privacy Extension Blocks Script
Problem: Privacy extensions (uBlock Origin, Privacy Badger) block heatmap scripts.
Solution:
- This is normal—no need to "fix" it
- Use incognito/private browsing to test without blockers
- Document that some users won't be tracked (expected)
- Focus on tracking genuine visitors, not privacy-conscious users
Issue 4: Mobile Tracking Issues
Problem: Mobile heatmaps show incomplete data.
Solution:
- Most tools default to mobile tracking, but verify settings
- Check that app tracking is enabled (if mobile app)
- For web, ensure responsive design isn't breaking script
- Review mobile-specific heatmaps separately from desktop
Issue 5: Script Not Found After Deployment
Problem: Script appears in dev but not in production.
Solution:
- Verify you deployed changes (check deployment logs)
- Clear browser cache and hard refresh (Ctrl+Shift+R)
- Check console for 404 errors on script file
- Verify script path doesn't have typos (especially for self-hosted scripts)
Best Practices for Installation
Do:
- ✓ Install to all pages (set trigger to "All Pages" in GTM)
- ✓ Use async script loading (default in all modern tools)
- ✓ Test in incognito/private browsing to avoid cache issues
- ✓ Wait 24 hours before analyzing—let data accumulate
- ✓ Use native plugins when available—simpler to maintain
Don't:
- ✗ Duplicate scripts (only one instance per site)
- ✗ Block scripts with privacy extensions during testing
- ✗ Add scripts to
<head>if alternative locations offered - ✗ Assume installation failed if no data appears in 5 minutes
- ✗ Install multiple heatmap tools on high-traffic sites without testing speed impact
FAQ
How long after installation does heatmap data appear?
Most tools show initial data within 5-15 minutes. Hotjar and Crazy Egg may take 10-30 minutes. Full heatmaps (needing 50+ session samples) may take 1-2 hours to generate. Check your tool's documentation for exact expectations.
Do I need to install heatmaps on every page?
Set your installation to "all pages" when possible. Some pages (checkout, login) might be excluded for privacy reasons, but for analysis, comprehensive coverage is best. Most tools allow page-level filtering later.
Will heatmap tracking slow down my website?
Modern heatmap tools (Clarity, Hotjar, Crazy Egg) load asynchronously and have minimal impact (under 50ms load time). However, multiple tracking scripts can compound. Combine tracking under GTM or use a single primary tool.
What's the difference between Site ID and Account ID?
- Site/Project ID: Unique identifier for your website within the heatmap tool
- Account ID: Your overall account identifier Always use the Site ID—it's what appears in most installation codes.
Can I install a heatmap if I don't have code access?
Yes:
- Use Google Tag Manager (works on many platforms)
- Use native platform plugins (WordPress, Shopify)
- Ask your web host or developer to add the script
- For no-code sites, ask the platform directly
Do I need to install heatmaps on staging and production separately?
Ideally yes—use separate projects:
- Staging project: Test heatmap functionality
- Production project: Live user tracking
This prevents staging traffic from polluting production data.
Is it safe to install heatmap scripts?
Yes, from reputable tools (Clarity, Hotjar, Crazy Egg, PostHog). These are industry-standard tools used on millions of websites. That said:
- Review privacy policies before installing
- GDPR compliance may require user consent in Europe
- Inform users about tracking in your privacy policy
- Use Consent Management Platforms for explicit opt-in if required
Conclusion
Installing a heatmap is straightforward—usually under 15 minutes from start to verified tracking. Choose your installation method based on your setup:
- Easy: Use native plugins (WordPress, Shopify)
- Flexible: Deploy via Google Tag Manager
- Direct: Copy-paste script directly into your codebase
After installation, wait for data collection, then analyze what users are actually doing on your site.
The hardest part isn't installation—it's acting on the insights. But with heatmaps installed and tracking user behavior, you're positioned to make data-driven optimization decisions.
Want simpler heatmap analytics with fair pricing? UXHeat is launching soon with a focus on what matters most—clear insights without complexity. Join the waitlist to get early access.