Skip to content

(#5275) Add Tracking to WYSIWYG Link Clicks on Blog Posts#5281

Open
dev-rana-publicis wants to merge 1 commit into
developfrom
ticket/5275-blog-analytics
Open

(#5275) Add Tracking to WYSIWYG Link Clicks on Blog Posts#5281
dev-rana-publicis wants to merge 1 commit into
developfrom
ticket/5275-blog-analytics

Conversation

@dev-rana-publicis

Copy link
Copy Markdown
Contributor

Closes #5275

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Adds NCIDS inner-page analytics tracking for link clicks inside blog post body WYSIWYG content to restore the expected Inner:WYSIWYG:LinkClick event behavior after the blog migration.

Changes:

  • Import and initialize bodyLinkAnalyticsHelper on blog pages.
  • Add a guarded cgdpBodyAnalyticsInit() that locates the NCIDS full HTML WYSIWYG container and wires click listeners on DOMContentLoaded.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +24 to +29
// Verify both elements exist before running helper
if (blogsBodySection && blogsBodyParent) {
// NOTE: There should only ever be one instance of the
// body section on the page, so we can hardcode the section index to 0
bodyLinkAnalyticsHelper(blogsBodyParent as HTMLElement, 0);
blogsBodyAnalyticsInit = true;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@davisaw @welshja Can you confirm if this is still a requirement? Ideally this should've been found when the shared analytics handler was created in #4911 but we can add it here or in #5257

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.

If this is resolved ^ this PR is good with me

Comment on lines 34 to 43
@@ -16,6 +39,7 @@ const onDOMContentLoaded = () => {
cgdpEmbedVideoInit();
cgdpEmbedCardInit();
cgdpDefinitionInit();
cgdpBodyAnalyticsInit();
};

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I verified blog post pages load the NCIDS blog entrypoint analytics, and the legacy cgov_common blog-body handler referenced in the review is not the runtime path for these pages. Because of that, this comment is not applicable to the scope of this PR and we won’t fix this.

@cgdp-management-server

Copy link
Copy Markdown

ODE Deployment

Code has been deployed to ODE 1146.

@dev-rana-publicis
dev-rana-publicis marked this pull request as ready for review June 24, 2026 20:50
@davisaw

davisaw commented Jun 25, 2026

Copy link
Copy Markdown

Blog body links are now firing the correct Inner:WYSIWYG:LinkClick event!
However, external feature cards are also firing the Inner:WYSIWYG:LinkClick when they should only fire the
Body:EmbeddedCard:LinkClick. I'm looking at https://ncigovcdode1146.prod.acquia-sites.com/news-events/cancer-currents-blog/2019/blog-post-feature-card-embed-test-page
Other components like internal feature cards, embedded media, infographics, etc. all look good.

@dev-rana-publicis
dev-rana-publicis force-pushed the ticket/5275-blog-analytics branch from 2919a1a to 7fc23df Compare June 25, 2026 18:09

@davisaw davisaw left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Looks good! External feature cards now firing just one analytics event. Body links, glossified links, and other embedded content still firing correctly.
Also, it's okay that link text is not truncated to 50 characters. Adobe truncates to a character limit in our reporting

@dev-rana-publicis
dev-rana-publicis requested a review from a team June 29, 2026 14:32
@andyvanavery31
andyvanavery31 removed the request for review from welshja June 30, 2026 14:14
@dev-rana-publicis
dev-rana-publicis force-pushed the ticket/5275-blog-analytics branch from 7fc23df to 9cfe4a2 Compare June 30, 2026 14:43
@dev-rana-publicis
dev-rana-publicis force-pushed the ticket/5275-blog-analytics branch from 9cfe4a2 to c38a996 Compare July 2, 2026 18:31
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.

Analytics | Add Tracking to WYSIWYG Link Clicks on Blog Posts

6 participants