Repository navigation
contextual: expose page emotions via ctxEmotions() and the ctx_emotion key-value - #381
Merged
Merged
Conversation
…n key-value Add ContextualEmotion and classifications.emotions, a ctxEmotions() accessor, and the multi-value ctx_emotion GAM key-value (ids only, omitted when empty). options.emotionKey renames the key, and "" opts out. Update the README, gpt.md and the ctx_segments demos. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
hashibit
reviewed
Nov 3, 2026
hashibit
left a comment
There was a problem hiding this comment.
Review notes below. Items on contextual_segments.ts:179/373 and the README note are the ones I would fix before merge. The others are smaller.
Not from this PR, for a follow-up: setContextualTargetingInGAM (lib/addons/gpt.ts) never clears keys it set before. On an SPA route change to a page with no emotions, the old ctx_emotion value stays on GAM page targeting. ctx_kw and ctx_sentiment have the same gap today.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
willmacd
approved these changes
Nov 3, 2026
hashibit
approved these changes
Nov 3, 2026
mosherBT
approved these changes
Nov 3, 2026
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Why
/v1beta1/contextualnow returnsclassifications.emotions, but the SDK doesn't surface it. Publishers have no way to read it or target on it.What Changed
contextual_segments: newContextualEmotiontype andemotionsfield onContextualClassifications.sdk: newctxEmotions()accessor. It reads the cachedctxSegments()response and returns[]when the page has no emotions.ctxTargetingKeyValues: emits the multi-value keyctx_emotionwith the emotion ids. Scores aren't sent and the SDK applies no cutoff. The key is omitted when the page has no emotions.options.emotionKeyrenames the key, and""opts out.lib/addons/gpt.md.ctx_segmentspages show the emotions.How to Test
.mdalongside the code (for examplelib/addons/<addon>.md) and the matching README section. New addons ship with a new.md.Notes
🤖 Generated with Claude Code