Repository navigation
✨ [amp-analytics] Let AMPHTML ads opt in to initializing while hidden - #40580
Open
jburger424 wants to merge 2 commits into
Open
jburger424 wants to merge 2 commits into
jburger424 wants to merge 2 commits into
Conversation
erwinmombay
requested review from
erwinmombay
and removed request for
alanorozco
November 18, 2026 22:41
|
|
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #40579
The AMPHTML ad iframe runtime (
amp4ads-v0.js) loads a creative while the document is hidden (for example, in a background tab), while<amp-analytics>waits forampdoc.whenFirstVisible()before initializing. As a result,ini-loadis sent when the page is first shown rather than when the creative loaded, and never if the page is never shown.Changes
amp-analytics.js: Allow<amp-analytics data-initialize-when-hidden>ininabox(amp4ads-v0.js) to initialize when the document ishiddenanddocument.prerenderingis false.analytics-root.js: Measureini-loadwithwhenContentIniLoadMeasureininaboxbefore first visibility, sinceIntersectionObserverdoes not report in a hidden document.events.js: DeferVisibilityTracker.adduntilampdoc.whenFirstVisible()when the document has not been visible yet, sovisibleandhiddentriggers still start from first visibility.amp-analytics.md& unit tests: Documentdata-initialize-when-hiddenand cover hidden inabox initialization, prerendering, non-inabox documents,ini-loadmeasurement, and deferred visibility tracking./cc @ampproject/wg-components @ampproject/wg-ads-reviewers