DEV Community

yulingg zhang
yulingg zhang

Posted on Fully Autonomous

An element entering the viewport is not the same as a survey impression

An optional question below a useful tool can help distinguish different visitor intents. But its denominator needs care. A page view does not prove that someone reached the question, and an unanswered question does not reveal their preference.

I maintain RetroPrompt, where a page now asks whether visitors want a still portrait, a video template, or are simply exploring. This article was prepared with AI assistance and describes the measurement implementation, not a finding about visitor preferences.

Define exposure before reporting an answer rate

The question sits after the copy and generator controls so that answering it is not a prerequisite for using the page. That means some visitors may finish their task without ever seeing the question.

For this implementation, exposure means that at least half of the panel intersects the viewport. The number is an operational definition, not proof of attention or reading. Sticky headers, overlays, background tabs and fast scrolling can still make the signal imperfect.

There is an easy IntersectionObserver trap: supplying threshold: 0.5 does not make every callback entry a half-visible impression. Check the entry's actual intersection ratio as well as isIntersecting.

let recorded = false;
const observer = new IntersectionObserver(entries => {
  const visibleEnough = entries.some(entry =>
    entry.isIntersecting && entry.intersectionRatio >= 0.5
  );
  if (visibleEnough && !recorded) {
    recorded = true;
    recordExposure();
    observer.disconnect();
  }
}, { threshold: 0.5 });
observer.observe(questionPanel);
Enter fullscreen mode Exit fullscreen mode

This sketch assumes the panel can fit sufficiently inside the viewport. A very tall panel needs a different visibility target. It also leaves telemetry delivery, consent and browser support handling to the application.

Keep unanswered sessions visible

Report question-seen sessions, answered sessions, first-choice counts and unanswered sessions separately. A session that never answered is not a vote for the default option. An explicit “just exploring” answer is different from silence.

Allow visitors to change the visible selection, but decide which behavior your report measures. If the question is about the initial reason for arriving, the first expressed choice is one reasonable convention. If it concerns the final preferred output, that convention may be wrong. State the rule in the report instead of changing it after looking at the results.

Test the boundary, not only the happy path

Test a panel with only a small strip visible, then scroll until the threshold is met. Exposure should appear only after the second step. Test repeated observer callbacks, repeated clicks, a changed answer and a reload within the same session.

Also exclude your own test session from the audience report. A tiny site's survey can otherwise be dominated by the developer verifying the buttons. In the browser, a click can record exposure as a fallback for an interaction that arrives before the observer callback; the reporting layer must still deduplicate the session.

Finally, self-selected survey answers are not the same as demand or willingness to pay. Compare them with actual useful actions, and report the uncertainty when the sample is small.

The example interface is on RetroPrompt's OSM guide. I maintain the site. It currently offers static portrait generation and prompts, not video-template export.

Top comments (0)