Skip to content

Count sponsor impressions on view, not mount - #1497

Open
busbyk wants to merge 1 commit into
mainfrom
busbyk/nwacus/web-issue-1486
Open

busbyk wants to merge 1 commit into
mainfrom
busbyk/nwacus/web-issue-1486

Conversation

@busbyk

@busbyk busbyk commented Nov 9, 2026 •

Copy link
Copy Markdown
Collaborator

Description

sponsor_impression fired when SponsorLink mounted, so it counted "the page rendered the block," not "someone saw it." It now fires when at least half of a sponsor link has been in the viewport for one continuous second, at most once per link per page view. sponsor_click and the event properties are unchanged.

Related Issues

Closes #1486

Parent: #1484 — Spec: PostHog across AvyApp, AvyWeb and the NAC widgets

Key Changes

  • SponsorLink uses an IntersectionObserver at a 0.5 threshold plus a one-second timer. Dropping below half cancels the timer, and the observer disconnects once the impression fires.
  • Tests rewritten around the new behavior with a fake observer and fake timers.

How to test

On a page with a sponsor block below the fold (seeded: /blocks) and NEXT_PUBLIC_POSTHOG_KEY set, confirm no impression on load or on a quick scroll past, exactly one per link after a second in view, none on scrolling away and back, and sponsor_click on click. PostHog drops events from headless browsers.

Checked in Chromium against the dev server with PostHog traffic intercepted locally. The seed has one sponsor per center, so a carousel with several sponsors wasn't exercised.

Screenshots / Demo video

N/A: no visual change.

Migration Explanation

None.

Future enhancements / Questions

Before deploying

  • Add a project-wide PostHog annotation dated to the planned production release, so pre- and post-change counts aren't compared. If the release date moves, update the annotation to match. The Sponsor performance dashboard becomes meaningful from that date.

Questions for the team

The issue asks for "at most once per sponsor per page view, when at least half of the sponsor link is visible." This PR departs from that in two ways, following Media Rating Council (MRC) ad-measurement guidance. Are we happy with both?

  1. Count once per placement, not once per sponsor? A sponsor in two blocks on a page gets two impressions. The MRC says that with multiple ads on a page, each ad should be measured and reported independently. Clicks are already counted per link, so one impression across two blocks would overstate click-through rate, and PostHog can still report unique users or sessions per sponsor for reach. That guidance covers paid ads and doesn't address one advertiser in several slots directly, so it's the nearest match rather than a direct ruling.
  2. Require one continuous second in view? The issue only asks for the 50%. The MRC definition of a viewable display ad is 50% of pixels for one continuous second. With it, a quick scroll past a block doesn't count and we can tell sponsors the numbers follow the industry definition, but counts will be lower than the issue's rule would give.

🤖 Generated with Claude Code


Autofix with [code]smith
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

An impression now needs half the link in the viewport for one continuous
second, once per link per page view, matching the MRC viewable display
ad definition.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

@busbyk
busbyk requested review from rchlfryn and rustynwac November 9, 2026 21:15
@rustynwac

Copy link
Copy Markdown
Contributor

@busbyk very cool follow up in general to all this. We're going to be more dialed than the marketing teams asking for the data. I double checked with NWAC:

-yes, count once per placement, not once per sponsor. there will be multiple ads rotating thru the page at once the way the carousel works
-yes, I think 50% of pixels for one continuous second makes since to count as an impression, especially if that’s industry standard for ads

This branch was successfully deployed

1 active deployment
Preview — 36b5b140 Deployed Nov 9, 2026 by busbyk via build #3291
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Sponsor impressions: count views, not mounts, and report per sponsor

2 participants