Predictive Eye Tracking Heatmap Generator for UX Research
This tutorial shows how to build a predictive eye tracking heatmap generator using AI tools like ChatGPT, Claude, and Cursor. The prompt was originally published by prompts.chat and uses cognitive science principles to simulate human visual attention patterns. You'll learn how to structure the app's UI, implement core logic for heatmaps, test functionality, and deploy it free. This tool helps UX researchers understand where users look first on interfaces.
The process involves using AI coding assistants to generate a working HTML application that overlays thermal heatmaps onto screenshots based on Gestalt principles, cognitive load theory, and biological priority rules.
What you need
- Access to an AI coding assistant (ChatGPT, Claude, Cursor, Lovable, Bolt, or v0)
- A screenshot of a UI element to test the heatmap generator
- Basic knowledge of HTML, CSS, JavaScript, and image processing concepts
- A code editor like VS Code or any online editor
- GitHub account for deployment (optional but recommended)
- Browser with developer tools to inspect output
The full prompt
{
"system_configuration": {
"role": "Senior UX Researcher & Cognitive Science Specialist",
"simulation_mode": "Predictive Visual Attention Modeling (Eye-Tracking Simulation)",
"reference_authority": ["Nielsen Norman Group (NN/g)", "Cognitive Load Theory", "Gestalt Principles"]
},
"task_instructions": {
"input": "Analyze the provided UI screenshots of web/mobile applications.",
"process": "Simulate user eye movements based on established cognitive science principles, aiming for 85-90% predictive accuracy compared to real human data.",
"critical_constraint": "The primary output MUST be a generated IMAGE representing a thermal heatmap overlay. Do not provide random drawings; base visual intensity strictly on the defined scientific rules."
},
"scientific_rules_engine": [
{
"principle": "1. Biological Priority",
"directive": "Identify human faces or eyes. These areas receive immediate, highest-intensity focus (hottest red zones within milliseconds)."
},
{
"principle": "2. Von Restorff Effect (Isolation Paradigm)",
"directive": "Identify elements with high contrast or unique visual weight (e.g., primary CTAs like a 'Create' button). These must be marked as high-priority fixation points."
},
{
"principle": "3. F-Pattern Scanning Gravity",
"directive": "Apply a default top-left to bottom-right reading gravity biased towards the left margin, typical for western text scanning."
},
{
"principle": "4. Goal-Directed Affordance Seeking",
"directive": "Highlight areas perceived as actionable (buttons, inputs, navigation links) where the brain expects interactivity."
}
],
"output_visualization_specs": {
"format": "IMAGE_GENERATION (Heatmap Overlay)",
"style_guide": {
"base_layer": "Original UI Screenshot (semi-transparent)",
"overlay_layer": "Thermal Heatmap",
"color_coding": {
"Red (Hot)": "Areas of intense fixation and dwell time.",
"Yellow/Orange (Warm)": "Areas scanned but with less dwell time.",
"Blue/Transparent (Cold)": "Areas likely ignored or seen only peripherally."
}
}
}
}1Choose an AI Tool and Paste the Full Prompt
Start by selecting one of the supported AI coding tools. I recommend using ChatGPT or Claude as they understand complex scientific prompts well. Open your chosen AI assistant and paste the full prompt exactly as it appears on this page.
After pasting, ask the AI to generate a complete working HTML application that simulates eye tracking heatmaps based on cognitive science principles. Ensure the output includes:
- A basic HTML structure with canvas elements
- JavaScript logic for heatmap generation
- UI components like file upload and preview buttons
- Visual overlay styling matching the color guide from the prompt
Tip: If you get too much code or an overly complex output, ask the AI to simplify by focusing only on core logic first.

Pro tip: Always start with a clean slate in your AI editor before pasting the prompt.
2Review and Modify Generated Code for Compatibility
Once the AI generates code, review it carefully. Look for issues like incorrect image handling or missing dependencies.
The initial output may include:
- Incomplete HTML structure
- Missing canvas rendering logic
- Incorrect color mappings
- Lack of user interaction elements
If you're using a tool like Cursor, you can edit the generated code directly in your IDE. If using ChatGPT or Claude, copy the code into a local file and test.
Ensure that:
- The app accepts image uploads
- Canvas is initialized correctly
- Heatmap colors follow the prompt's guidelines (red for hot zones, blue for cold)
Tip: If your AI output doesn’t include file upload functionality, add <input type="file" id="imageUpload"> to the HTML.
Pro tip: Use a local server like Live Server in VS Code to test dynamic features.
3Implement Core Data Model and UI Components
The core data model for this app consists of:
- Input image data (UI screenshot)
- Heatmap grid matrix representing visual priority
- Color intensity mapping based on cognitive rules
- User interaction points (click, hover)
Create a basic UI with these components:
- File upload section
- Preview area for the UI screenshot
- Canvas element to render the heatmap overlay
- Buttons to trigger simulation and reset
Ensure that the color coding matches the prompt:
Red = High fixation (hot zones)
Yellow/Orange = Moderate scanning
Blue/Transparent = Peripheral or ignored areas
Tip: Use a JavaScript library like html2canvas or fabric.js for advanced rendering if needed.

Pro tip: Break your UI into semantic HTML elements to support accessibility.
4Integrate Cognitive Science Rules Into Heatmap Logic
Now implement the scientific rules engine from the prompt. The four key principles are:
- Biological Priority, Highlight faces or eyes with red zones.
- Von Restorff Effect, Mark high-contrast CTAs as fixation points.
- F-Pattern Scanning Gravity, Apply left-to-right scanning gravity.
- Goal-Directed Affordance Seeking, Highlight interactive elements.
In code, simulate these using:
- Image analysis for facial features (use libraries like OpenCV.js or TensorFlow.js)
- Contrast detection algorithms
- Predefined scan paths for layout priority
- Interactive element detection
Test each rule individually before combining them into a single simulation.
Tip: For simplicity, start with a hardcoded heatmap grid and gradually add logic.
Pro tip: Simulate facial detection using basic image segmentation techniques.
5Test Each Feature With Sample Input
Upload a sample UI screenshot to test the app’s functionality. Ensure that:
- The original image renders correctly
- The heatmap overlay appears on top
- Color intensity matches cognitive rules
- Interactive elements trigger expected behaviors
Use browser dev tools to inspect the canvas and verify color values. If certain areas aren't highlighted, adjust your rule implementation.
Try different UI types:
- Mobile app screen
- Web dashboard
- E-commerce product page
This helps validate that the logic adapts to various layouts and visual designs.
Tip: Add console logs to debug heatmap intensity values at each stage.
Pro tip: Use a screenshot with clear CTAs, text, and faces for better testing.
6Fix Bugs and Optimize Simulation Accuracy
After initial testing, you might notice inaccuracies or missing features. For example:
- Heatmap does not highlight CTAs properly
- Faces are missed in the image analysis
- Scanning gravity doesn’t apply to all areas
To fix these:
- Add more detailed contrast checks for CTAs
- Implement a simple facial detection algorithm (e.g., using
jsfeatorface-api.js) - Adjust scan path logic based on layout structure
- Refine heatmap blending technique to ensure semi-transparency
Iterate until the heatmap reflects cognitive principles closely. Ask your AI tool for specific fixes when needed.
Tip: Use small test images with known elements to validate each rule.
Pro tip: Use requestAnimationFrame for smoother canvas updates during simulation.
7Add State Management and Persistence
Integrate state management for:
- Current uploaded image
- Applied heatmap settings
- Simulation history
Use JavaScript’s built-in object storage or localStorage to persist:
- Last used screenshot
- Heatmap rendering options
- User preferences (e.g., color scheme)
Example structure:
const appState = {
currentImage: null,
heatmapData: [],
settings: {
scanGravity: 'left',
highlightCTA: true
}
};
Ensure that state persists across reloads and resets. This improves usability by allowing users to tweak settings without re-uploading images.
Tip: Avoid storing large image data in localStorage, store only metadata or base64 URLs.
Pro tip: Use a simple JSON object for app state instead of complex frameworks.
8Deploy the App Free Using GitHub Pages or Netlify
Once your app works locally, deploy it using free hosting platforms:
- GitHub Pages: Push code to a new repo and enable Pages in settings
- Netlify: Drag-and-drop upload or connect a Git repo
Ensure that:
- All files are in the correct directory structure
- Canvas rendering works without local file access issues
- Images load correctly from CDN or local paths
GitHub Pages is ideal for static sites like this. Netlify offers more flexibility and auto-deployment on commits.
Test deployment by visiting your live URL and confirming all features work as expected.
Tip: Add a robots.txt to prevent indexing if needed.
Pro tip: Use GitHub Actions for automated builds and deployments.
9Ensure Accessibility and Responsive Design
To make your app accessible:
- Use semantic HTML elements (
<label>,<input>, etc.) - Add ARIA attributes where needed
- Ensure keyboard navigation support
- Provide alternative text for images
For responsive design:
- Set canvas width/height to 100% of container
- Adjust layout using CSS Grid or Flexbox
- Test on mobile and desktop screen sizes
Accessibility is crucial for UX research tools. Users must be able to interact with the heatmap generator regardless of device or disability.
Tip: Test with screen readers like NVDA or VoiceOver to confirm proper labeling.
Pro tip: Use alt tags and labels to describe all interactive elements.
10Finalize Features and Prepare for Sharing
Before sharing your creation:
- Double-check that all cognitive science rules are implemented correctly
- Add a README.md explaining how to use the tool
- Document assumptions about input images (size, format)
- Include screenshots or GIFs showing usage
Share your project via GitHub or a portfolio site. Consider adding:
- A demo video
- Instructions for customization
- Links to related research
Make sure it's clear how others can replicate the app using AI tools like those mentioned.
Tip: Add a license file (MIT or Creative Commons) if you plan to open-source it.
Pro tip: Include a brief usage guide in your README for new users.
11Follow Up with Additional Prompts for New Features
Once the basic version works, try extending functionality using follow-up prompts. For example:
- Add export to PNG or SVG
- Simulate multiple users or heatmaps in one view
- Include eye movement animation overlay
- Integrate real-time user data (via browser APIs)
Use the original prompt as a base and ask your AI assistant to:
- Enhance visual feedback
- Add animation for heatmap transitions
- Support batch uploads
- Improve rule accuracy using machine learning models
This iterative approach allows you to build upon your initial model and create more advanced versions.
Tip: Start with one enhancement at a time to maintain stability.
Pro tip: Ask AI to generate UI components for additional controls like zoom or filters.
Adapt it to your own brand
- Adapt the cognitive science rules to match industry-specific UX patterns (e.g., e-commerce, healthcare, education).
- Change color schemes to align with brand guidelines while maintaining readability and contrast.
- Modify heatmap intensity thresholds based on different user demographics or cultures.
- Support multiple input formats like PDFs, SVGs, or mobile screenshots for broader compatibility.
- Add support for custom heatmaps using machine learning models trained on real eye-tracking data.
- Integrate with design tools like Figma or Sketch to import UI designs directly into the heatmap generator.
- Enable collaboration features where users can share heatmaps and annotations with team members.
Common mistakes and fixes
- Not testing each cognitive rule independently before combining them. Fix by implementing rules step-by-step.
- Ignoring image transparency when overlaying heatmaps. Fix by using semi-transparent canvas rendering.
- Using hardcoded values instead of dynamic data structures for heatmap intensity. Fix by adding a matrix or grid system.
- Failing to consider accessibility during UI development. Fix by testing with screen readers and keyboard navigation.
- Not handling different screen sizes or aspect ratios. Fix by using responsive CSS techniques and media queries.
- Overcomplicating the initial build with too many features. Fix by focusing on core logic first, then adding complexity.
Frequently asked questions
What cognitive science principles does this tool use?
It uses principles from Nielsen Norman Group, Gestalt theory, and Cognitive Load Theory to simulate human visual attention patterns.
Can I run this app offline after building it?
Yes, once built as a static HTML file, you can open index.html in any browser without internet access.
Which AI tools work best for this project?
ChatGPT and Claude are most effective due to their ability to understand complex prompts and generate structured code.
How accurate is the simulation compared to real eye-tracking data?
The simulation aims for 85-90% predictive accuracy, using established scientific models as a reference point.
Final thoughts
This tutorial walked you through building a predictive eye tracking heatmap generator using AI tools. You learned how to implement cognitive science principles into code, test each feature, and deploy a functional app for free. The key was following the prompt closely while iterating on output to ensure accuracy and usability.
Now it's your turn. Copy the full prompt above and start building your own version of this powerful UX research tool.