Skip to content

[BRANDCON-8316] Instrument analytics for BC in-chat navigation behavior - #6579

Open
loganzartman wants to merge 13 commits into
stagefrom
akarte/BRANDCON-8316
Open

[BRANDCON-8316] Instrument analytics for BC in-chat navigation behavior#6579
loganzartman wants to merge 13 commits into
stagefrom
akarte/BRANDCON-8316

Conversation

@loganzartman

@loganzartman loganzartman commented Aug 26, 2026

Copy link
Copy Markdown

adds analytics for when users navigate back from an outgoing same-tab link.

  • adds navigation:backNavigation analytics event type matching spec in https://jira.corp.adobe.com/browse/BRANDCON-8316
    • emitted on: bfcache (pageshow), and non-cached back/forward (via performance entries check)
  • augments BC client onEvent to record link information in browser history entry

depends on web client PR: https://github.com/adobe-brand-concierge/acom-brand-concierge-web-agent/pull/247
but merge/deploy order is not important

Resolves: BRANDCON-8316

Test URLs:

sample payloads

CTA click:

{
  "eventType": "navigation:backNavigation",
  "data": {
    "clickType": "product_card_cta",
    "sessionId": "e973c3ad-1a5a-4b01-bd9f-765d5b58d4e1",
    "sourcePage": "http://localhost:6456/drafts/nala/blocks/brand-concierge/brand-concierge",
    "destinationPage": "https://business.adobe.com/products/brand-visibility.html",
    "loginStatus": "logged-in",
    "navigatedBack": true
  }
}

Inline hyperlink:

{
  "eventType": "navigation:backNavigation",
  "data": {
    "clickType": "inline_hyperlink",
    "sessionId": "e973c3ad-1a5a-4b01-bd9f-765d5b58d4e1",
    "sourcePage": "http://localhost:6456/drafts/nala/blocks/brand-concierge/brand-concierge",
    "destinationPage": "https://business.adobe.com/products/brand-visibility.html",
    "loginStatus": "logged-in",
    "navigatedBack": true
  }
}

@aem-code-sync

aem-code-sync Bot commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

Hello, I'm the AEM Code Sync Bot and I will run some actions to deploy your branch.
In case there are problems, just click the checkbox below to rerun the respective action.

  • Re-sync branch
Commits

onEvent: (event) => {
if (event.eventType === 'card:clicked') recordBcNavClick('product_card_cta', event.data?.element?.productPageURL);
else if (event.eventType === 'cta:clicked') recordBcNavClick('cta', event.data?.element?.productPageURL);
else if (event.eventType === 'link:clicked') recordBcNavClick(event.data?.element?.linkType ?? 'inline_hyperlink', event.data?.element?.href);

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

new event type; pending acom-brand-concierge-web-client PR

Covers getChatSessionId cookie parsing and the bcAnalytics
navigation:backNavigation payload (event name + required fields).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@loganzartman
loganzartman marked this pull request as ready for review August 27, 2026 00:01

@JasonHowellSlavin JasonHowellSlavin left a comment

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.

LGTM. I might review the comments, we tend to try and be as comment free in our code in Milo.

The only thing staying approval on my end is that everything done here should also be done in /libs/c2/blocks/brand-concierge

Comment on lines +301 to +303
if (event.eventType === 'card:clicked') recordBcNavClick('product_card_cta', event.data?.element?.productPageURL);
else if (event.eventType === 'cta:clicked') recordBcNavClick('cta', event.data?.element?.productPageURL);
else if (event.eventType === 'link:clicked') recordBcNavClick(event.data?.element?.linkType ?? 'inline_hyperlink', event.data?.element?.href);

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.

Seems like a decent spot to use a switch case.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

done


setCssGnavHeight();

const emitAnalyticsIfBackNav = () => {

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.

@loganzartman Can this be moved to bc-analytics.js? We recently did a massive refactor to cut down on extraneous stuff in the base block code and this being an analytics specific function, it seems a good fit to move there.

Also, there is a brand-concierge-global block that will likely need this same treatment. It imports from the base brand-concierge block, so moving to bc-analytics will be helpful for that block also:

https://github.com/adobecom/milo/blob/stage/libs/blocks/brand-concierge-global/brand-concierge-global.js

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

yeah, that's a good idea. I've pulled everything into bc-analytics with a single initAnalytics hook for the block. does that seem good?

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.

Seems ok, there are other analytics elements to this that are invoked when the web client is bootstrapped and as long as the rest of it still works, then this looks great.

Again, though, we should add this to the brand-concierge-global block (the one that is used for gnav as seen on bacom stage here so it gets this goodness as well:

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

sorry, I misread your first comment. I've added the init call to brand-concierge-global as well. I didn't realize these were both the brand concierge block.

loganzartman and others added 3 commits August 31, 2026 11:08
Thread the widget's cta:clicked `source` enum through history state into
the navigation:backNavigation payload, so back-nav events are attributable
to the CTA surface. Use an options object for recordNavClick.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Comment thread libs/blocks/brand-concierge/bc-analytics.js Outdated

@colloyd colloyd left a comment

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.

Looks good!

@colloyd
colloyd requested a review from JackySun9 August 31, 2026 20:19
@colloyd

colloyd commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

@loganzartman So we are trying to do some testing on the milo code contributions here, but the name format of the source branch is making it impossible to test, specifically the "/" and caps in the branch name. If we rename so we can test it, it will close the PR.

For context, we might ordinarily test something like this using one of two methods:

An AEM url, using this pattern: https://[branch-name]--milo--adobecom.aem.page/[path to test page]
Or on a stage page, like so: https://business.stage.adobe.com?milolibs=[branch-name]

Neither of these methods will work with the current branch name format.

As an alternative to renaming and hence closing your pr, you can push this same set of changes to a new branch, such as a simple: brandcon-8316

That way we could test your proposed changes using that other branch name without closing this PR.

@loganzartman

loganzartman commented Aug 31, 2026

Copy link
Copy Markdown
Author

ok, pushed to brandcon-8316: #6608
@colloyd

@JackySun9

Copy link
Copy Markdown
Contributor

@loganzartman do we need to wait for https://github.com/adobe-brand-concierge/acom-brand-concierge-web-agent/pull/247 get merging before do any validation? and if you can give some user cases to check, what will be better

@disha-akarte

Copy link
Copy Markdown

@loganzartman do we need to wait for https://github.com/adobe-brand-concierge/acom-brand-concierge-web-agent/pull/247 get merging before do any validation? and if you can give some user cases to check, what will be better

@JackySun9 I've asked Analysts to validate this, will let you know once we have a go ahead

@github-actions

github-actions Bot commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

Reminder to set the Ready for Stage label - to queue this to get merged to stage & production.

@github-actions

github-actions Bot commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

This pull request is not passing all required checks. Please see this discussion for information on how to get all checks passing. Inconsistent checks can be manually retried. If a test absolutely can not pass for a good reason, please add a comment with an explanation to the PR.

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.

5 participants