Skip to content

Reimplement event handler for mobile sticky slot#2421

Merged
cemms1 merged 20 commits intomainfrom
cemms1/reimplement-mobile-sticky-handler
Mar 9, 2026
Merged

Reimplement event handler for mobile sticky slot#2421
cemms1 merged 20 commits intomainfrom
cemms1/reimplement-mobile-sticky-handler

Conversation

@cemms1
Copy link
Copy Markdown
Contributor

@cemms1 cemms1 commented Feb 19, 2026

What does this change?

Re-introduces event handlers for launching the mobile-sticky ad slot from #2351.
This is being launched as an AB test while we understand the impact of the change.

The variant group of the AB test will implement the logic below. The control group will keep the existing logic in place.

We now listen to the following three events in order to determine whether we can render the mobile sticky slot:

  • banner:none
  • banner:close
  • banner:sign-in-gate
  • cmp:banner-close

The page is not eligible for mobile-sticky until we receive one of these events on a given page view. We also still need to check the existing criteria before rendering the mobile-sticky ad slot but these event listeners now act as an additional check.

After receiving an event, we double check whether the CMP is still on the screen just in case the cmp:banner-close event did not actually result in the dismissal of the CMP.

This PR adds logging and event handling for these three scenarios as well as a Playwright test to monitor this moving forward.

Note

Companion PR in dotcom-rendering guardian/dotcom-rendering#15380

Why?

The mobile-sticky slot can sometimes launch at the same time as the CMP and supporter revenue banners. When this happens, the slot is present in the DOM but sits underneath these elements. We can't continue to allow this to happen as impressions are counted against the advert in the slot even though it can't be seen by the end user

We have decided to only allow the mobile-sticky to launch after certain events as well as the existing page conditions.

It is worth noting that we deliberately allow display of the mobile-sticky slot when the sign in gate is the chosen message from the StickyBottomBanner component. The sign in gate currently appears most often obscuring the article body and does not look like a banner or a modal. Another version of the sign in gate appears as a modal and we may want to look into preventing ads running when this is present on the screen.


Co-authored by: @dskamiotis

Document link for extra information

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Feb 19, 2026

⚠️ No Changeset found

Latest commit: 22d1abd

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Feb 19, 2026

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Feb 19, 2026

Size Change: +213 B (+0.05%)

Total Size: 388 kB

Filename Size Change
bundle/dist/prod/artifacts/commercial/********************/graun.244.commercial.js 0 B -13.5 kB (removed) 🏆
bundle/dist/prod/artifacts/commercial/********************/graun.365.commercial.js 0 B -5.21 kB (removed) 🏆
bundle/dist/prod/artifacts/commercial/********************/graun.776.commercial.js 13.5 kB +13.5 kB (new file) 🆕
bundle/dist/prod/artifacts/commercial/********************/graun.821.commercial.js 0 B -20.6 kB (removed) 🏆
bundle/dist/prod/artifacts/commercial/********************/graun.841.commercial.js 5.21 kB +5.21 kB (new file) 🆕
bundle/dist/prod/artifacts/commercial/********************/graun.935.commercial.js 20.6 kB +20.6 kB (new file) 🆕
bundle/dist/prod/artifacts/commercial/********************/graun.consented-advertising.commercial.js 29 kB +121 B (+0.42%)
bundle/dist/prod/artifacts/commercial/********************/graun.standalone.commercial.js 19.2 kB +93 B (+0.49%)
bundle/dist/prod/artifacts/commercial/0af650f569ca350e6acd/[email protected] 2.57 kB +2.57 kB (new file) 🆕
bundle/dist/prod/artifacts/commercial/9b484c1f9d9641e7f338/[email protected] 0 B -2.57 kB (removed) 🏆
ℹ️ View Unchanged
Filename Size Change
bundle/dist/prod/artifacts/commercial/********************/graun.1.commercial.js 4.36 kB 0 B
bundle/dist/prod/artifacts/commercial/********************/graun.220.commercial.js 14.8 kB +2 B (+0.01%)
bundle/dist/prod/artifacts/commercial/********************/graun.284.commercial.js 617 B 0 B
bundle/dist/prod/artifacts/commercial/********************/graun.323.commercial.js 143 kB 0 B
bundle/dist/prod/artifacts/commercial/********************/graun.334.commercial.js 125 kB 0 B
bundle/dist/prod/artifacts/commercial/********************/graun.ad-free.commercial.js 4.75 kB +9 B (+0.19%)
bundle/dist/prod/artifacts/commercial/********************/graun.consentless-advertising.commercial.js 1.81 kB +1 B (+0.06%)
bundle/dist/prod/artifacts/commercial/********************/graun.Prebid.js.commercial.js 2.54 kB +1 B (+0.04%)

compressed-size-action

@cemms1 cemms1 force-pushed the cemms1/reimplement-mobile-sticky-handler branch 2 times, most recently from d5a3d9d to 0a5ebfc Compare February 19, 2026 13:21
@cemms1 cemms1 added feature Departmental tracking: work on a new feature labels Feb 19, 2026
@cemms1 cemms1 marked this pull request as ready for review February 19, 2026 13:34
@cemms1 cemms1 requested a review from a team as a code owner February 19, 2026 13:34
const handleBannerEvent = (event: Event) => {
log('commercial', '🪵 Handle Banner Event:', event.type);
const handleBannerEvent = (event: Event): void => {
log('commercial', `📲 Handling event ${event.type}`);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice touch with the enhanced logging - great addition for debugging and monitoring, as well as coupled to the event

Comment thread bundle/src/insert/mobile-sticky.ts Outdated
// We only try to load the mobile-sticky slot when one of the following events has been received
document.addEventListener('banner:close', handleBannerEvent);
document.addEventListener('banner:none', handleBannerEvent);
document.addEventListener('banner:sign-in-gate', handleBannerEvent);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This addition makes sense and aligns with the banner:sign-in-gate event handling introduced in the DCR codebase.

@cemms1 cemms1 changed the title Reimplement mobile sticky handler Reimplement event handler for mobile sticky slot Feb 19, 2026
@cemms1 cemms1 force-pushed the cemms1/reimplement-mobile-sticky-handler branch 6 times, most recently from 1154054 to b506bae Compare March 6, 2026 16:15
@cemms1 cemms1 force-pushed the cemms1/reimplement-mobile-sticky-handler branch from b506bae to 291fa20 Compare March 9, 2026 10:18
@cemms1 cemms1 requested review from a team and dskamiotis March 9, 2026 11:22
const bannerSelector = '[name="StickyBottomBanner"]';
const mobileStickySelector = '#dfp-ad--mobile-sticky';

/** TODO: Enable this when the event handling mobile-sticky logic goes live */
Copy link
Copy Markdown
Contributor Author

@cemms1 cemms1 Mar 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Couldn't opt into AB tests in playwright with a query parameter as the GET requests are updated to POST requests for interaction with the DCR prod server (as this is what runs in the container)

Once we go live to 100%, we can fully enable this test

@cemms1 cemms1 merged commit f2115c7 into main Mar 9, 2026
15 checks passed
@cemms1 cemms1 deleted the cemms1/reimplement-mobile-sticky-handler branch March 9, 2026 14:10
@gu-prout
Copy link
Copy Markdown

gu-prout Bot commented Mar 9, 2026

Seen on PROD (merged by @cemms1 2 minutes ago) Please check your changes!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature Departmental tracking: work on a new feature Seen-on-PROD

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants