✨ [Story analytics] Add caption state analytics events#2
Closed
michaeldegori wants to merge 1 commit into
Closed
Conversation
Mirrors the existing STORY_MUTED / STORY_UNMUTED analytics dispatch so
publishers can track caption toggles alongside audio mute toggles.
* Adds STORY_CAPTIONS_ON ('story-captions-on') and STORY_CAPTIONS_OFF
('story-captions-off') to StoryAnalyticsEvent.
* Subscribes to StateProperty.CAPTIONS_STATE in amp-story with
callToInitialize: false so the first emission is a user toggle, not
the default-on initialization.
* Documents both triggers in amp-story-analytics.md.
3 tasks
Owner
Author
|
Superseded by upstream PR ampproject#40505. |
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.
✨ [Story analytics] Add caption state analytics events
Summary
Adds analytics dispatch for the existing
StateProperty.CAPTIONS_STATEso publishers can track when users toggle captions on or off, mirroring the existingSTORY_MUTED/STORY_UNMUTEDevents.Why
Audio mute/unmute already emits analytics:
Captions are a parallel user-toggleable media state (
.i-amphtml-story-captions-buttonpaired with.i-amphtml-story-no-captions-button) but have no analytics surface today. Publishers can't measure caption engagement without it.Changes
story-analytics.js— adds two values to theStoryAnalyticsEventenum:STORY_CAPTIONS_ON: 'story-captions-on'STORY_CAPTIONS_OFF: 'story-captions-off'amp-story.js— subscribes toStateProperty.CAPTIONS_STATEnext to the existing mute-state analytics subscriber. UsescallToInitialize: falseso the default-on initialization does not fire an event; only user toggles do.amp-story-analytics.md— documents the two new triggers in the same voice as the existing "Mute trigger" / "Unmute trigger" entries.Naming notes
on/offmatches thecaptions-onhost attribute on the system layer (amp-story-system-layer.js) and reads more naturally thanenabled/disabled. Audio usesmuted/unmuted, captions useson/off, so each follows its own native vocabulary.captionsStatematches every otherCAPTIONS_STATEsubscriber in the codebase (amp-story-page.js,amp-story-system-layer.js) and the store-service typedef.Out of scope (intentional follow-up)
AnalyticsVariable.STORY_HAS_CAPTIONSparallel toSTORY_IS_MUTED. Publishers can distinguish state via the new event names; if reviewers prefer a variable for cross-event reporting parity I'm happy to add it in a follow-up.amp-story.jsis also untested (mirrored intest-analytics.jsandtest-amp-story.js). Happy to add coverage for both if preferred.Test plan
npx eslintclean on touched filesamp unit --files=extensions/amp-story/1.0/test/test-analytics.js— all 4 existing tests pass<amp-story-captions>and anamp-analyticslistener onstory-captions-on/story-captions-offSemantics check
StateProperty.CAPTIONS_STATEdefaults totruein the store. WithcallToInitialize: false, the first emission is the first user toggle, so an opening-tap that hides captions correctly firesSTORY_CAPTIONS_OFF(true → false). This matches the audio precedent's semantics.