Sub topic 7
Wire up hotspots and navigation
This chapter assumes you already have a single mapped user flow and a set of screens and states drawn for it. It also assumes you can read simple HTML and JavaScript. If you build in a design tool instead, the ideas apply directly. Only the click-to-link step differs.
What a hotspot is
A hotspot is a region of a screen that, when clicked or tapped, takes the participant to another screen. In a design tool you draw a rectangle over a button and pick a target frame. In plain HTML you mark an element with an attribute and let a script do the navigation.
Hotspots turn a stack of static screens into something a participant can use. They also decide what you can learn. A participant can only do what you wired up, so every link you add or leave out is a design decision about the test.
A minimal wiring in HTML
The prototype below has three screens: home, results and detail. Each button carries a data-goto attribute that names the screen it leads to. One click listener handles all of them and records each click in a log you can review after the session.
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Trip planner prototype</title>
</head>
<body>
<section id="home" class="screen">
<h1>Plan a weekend trip</h1>
<button data-goto="results">Search</button>
</section>
<section id="results" class="screen">
<h1>3 trips found</h1>
<button data-goto="detail">Lisbon, 2 nights</button>
<button data-goto="home">Back</button>
</section>
<section id="detail" class="screen">
<h1>Lisbon, 2 nights</h1>
<button data-goto="home">Start over</button>
</section>
<script>
const clickLog = [];
function show(id) {
document.querySelectorAll('.screen').forEach(function (s) {
s.hidden = s.id !== id;
});
}
document.addEventListener('click', function (e) {
const link = e.target.closest('[data-goto]');
if (!link) return;
clickLog.push({ to: link.dataset.goto, at: Date.now() });
show(link.dataset.goto);
});
show('home');
</script>
</body>
</html>How the code works
- Every screen is a
sectionwith the classscreen. Only one is visible at a time. show(id)loops over all screens and setshiddento true on every screen except the one whoseidmatches.- The listener is attached once to
document, not to each button. This is called event delegation. It means a new hotspot works as soon as you adddata-gototo an element, with no extra code. e.target.closest('[data-goto]')finds the nearest ancestor with the attribute. This matters when a hotspot contains other elements, such as an icon inside a button. The click lands on the icon, andcloseststill finds the button.show('home')at the end sets the starting screen.
After a session, type clickLog in the browser console to see the path the participant took.
Plan links from the flow
Draw the links before you write them. Take the flow from the earlier chapter and mark each arrow as a hotspot. Arrows that point back or sideways are as important as the forward ones, because participants use them when they are lost.
Sort the hotspots in your prototype into three kinds:
| Kind | Example | Why it matters |
|---|---|---|
| Path hotspot | Search, trip card | Moves the participant toward the task goal. |
| Escape hotspot | Back, Start over, logo | Lets a participant recover from a wrong turn. |
| Decoy hotspot | A second trip card that leads to a placeholder | Shows whether participants pick the option you expect. |
You do not need to wire every element on screen. You do need to decide, for each one, what happens when someone clicks it.
Log misses, not only hits
A click that lands on nothing is data. A participant who clicks a heading, a photo or a price expecting something to happen is telling you the design implies a link that does not exist. The basic script ignores those clicks. This version logs them too, and records which screen the participant was on.
const clickLog = [];
let current = 'home';
function show(id) {
const target = document.getElementById(id);
if (!target) {
console.warn('No screen named ' + id);
return;
}
document.querySelectorAll('.screen').forEach(function (s) {
s.hidden = s !== target;
});
current = id;
window.scrollTo(0, 0);
}
document.addEventListener('click', function (e) {
const link = e.target.closest('[data-goto]');
clickLog.push({
from: current,
to: link ? link.dataset.goto : null,
hit: Boolean(link),
at: Date.now()
});
if (link) show(link.dataset.goto);
});
show('home');Replace the contents of the script element with this code. Afterward, run console.table(clickLog) to see every click as a row. Rows with hit: false are your dead clicks. Three dead clicks on the same photo is a finding.
The script also warns in the console when a data-goto value matches no screen, and it scrolls to the top on each change so that a long screen does not leave the next one half scrolled.
Edge cases to handle
- CSS can defeat
hidden. If your stylesheet setsdisplay: flexordisplay: blockon.screen, it overrides thehiddenattribute and every screen shows at once. Add.screen[hidden] { display: none; }to your CSS. - The browser Back button leaves the prototype. Participants press it by habit. Because the script never changes the URL, Back may take them out of the prototype or to a blank page. If your test depends on Back, call
history.pushState({ id: id }, '', '#' + id)insideshowand listen forpopstateto callshowwith the stored id. If it does not matter, add a visible Back hotspot and tell the facilitator what to do if it happens. - States are screens too. An empty result list, an error message or a filled form is a separate
sectionwith its own id. Link to it from the hotspot that would trigger it. If you want to see how a participant reacts to an error, wire a specific input to lead there on purpose. - Dead ends. A screen with no outgoing hotspot traps the participant. Give each screen at least one escape, or decide that the end of the task is a valid dead end, such as a confirmation screen.
- Unlinked affordances. A button that looks clickable but does nothing makes participants think the prototype is broken. Either wire it to a short "Not part of this test" screen with a Back link, or style it so it does not look interactive.
- Keyboard and touch. Using
buttonelements, as above, gives you keyboard focus and tap support for free. Adivwith a click handler gives you neither. Use real buttons or links for anything clickable.
Common errors
| Symptom | Likely cause | Fix |
|---|---|---|
| Clicking a hotspot does nothing. | The `data-goto` value does not match any `id`, including case and spelling. | Check the console warning from the second script. |
| All screens appear at once. | CSS `display` overrides `hidden`. | Add `.screen[hidden] { display: none; }`. |
| Clicking an icon inside a button fails. | The listener checks `e.target` directly instead of using `closest`. | Use `e.target.closest('[data-goto]')`. |
| New screen opens scrolled down. | The previous scroll position carries over. | Call `window.scrollTo(0, 0)` in `show`. |
| Log is empty after the session. | The page was reloaded, which resets the array. | Keep the tab open, or save the log to `localStorage` on each click. |
Test the wiring before participants do
Walk every path yourself, then ask a colleague to click everything on every screen. Check three things:
- Every path hotspot reaches the screen you planned.
- Every screen has a way out.
- No hotspot silently fails.
Fix wiring bugs before the session. A participant who hits a broken link will blame the idea, and you will not be able to tell which problem you measured.
Exercise
In the second script, a participant on the results screen clicks the price text three times. What does clickLog contain for those clicks, and what might it mean for the design?
Show answer
It contains three rows with from: 'results', to: null and hit: false. Repeated dead clicks on the same element suggest the participant expected it to be a link, for example to see price details, so the design may need a link there or the price should not look clickable.
Exercise
A screen in your prototype shows all the content, but every time a participant moves between screens, the new screen opens halfway down the page. Which line fixes it, and where does it go?
Show answer
Add window.scrollTo(0, 0) inside show(id), after the screens are updated. That resets the scroll position each time the visible screen changes.