Skip to content

(#5278) Blog Analytics Helper#5291

Open
dlescarbeau wants to merge 3 commits into
developfrom
ticket/5278-blog-series-list-analytics
Open

(#5278) Blog Analytics Helper#5291
dlescarbeau wants to merge 3 commits into
developfrom
ticket/5278-blog-series-list-analytics

Conversation

@dlescarbeau

@dlescarbeau dlescarbeau commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

Closes #5278
Closes #5279
Closes #5280

@dlescarbeau
dlescarbeau marked this pull request as draft June 30, 2026 18:58
@dlescarbeau dlescarbeau changed the title (#5278) Blog series list analytics helper (#5278) Blog Analytics Helper Jun 30, 2026
@dlescarbeau
dlescarbeau force-pushed the ticket/5278-blog-series-list-analytics branch from 1f342ad to 76fe1c4 Compare July 1, 2026 14:38
@dev-rana-publicis
dev-rana-publicis requested a review from Copilot July 1, 2026 21:52

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 dedicated analytics tracking for NCIDS blog experiences (blog series list, right-rail links, and pager links) to meet the new EDDL event requirements from issues #5278#5280, while preventing legacy dynamic-list tracking from firing on legacy blog series pages.

Changes:

  • Introduces blog-analytics-helper with three analytics helpers that emit the required EDDL trackOther events.
  • Adds Jest tests validating payload shape, truncation, pageType handling, and “only once per click” behavior.
  • Updates the blogs entrypoint to initialize the new helpers and adjusts legacy jQuery analytics to skip blog series dynamic-list tracking.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
docroot/profiles/custom/cgov_site/themes/custom/ncids_trans/front-end/src/lib/core/analytics/blog-analytics-helper.ts Implements new EDDL click events for blog series list, right rail, and pager interactions.
docroot/profiles/custom/cgov_site/themes/custom/ncids_trans/front-end/src/lib/core/analytics/tests/blog-analytics-helper.test.ts Adds unit tests covering new tracking behavior and duplicate-handler prevention.
docroot/profiles/custom/cgov_site/themes/custom/ncids_trans/front-end/src/entrypoints/blogs/blogs.ts Wires the new analytics helpers into the blogs bundle on DOMContentLoaded.
docroot/profiles/custom/cgov_site/themes/custom/cgov/cgov_common/src/libraries/analytics/analytics.js Prevents legacy DynamicListItemClick tracking from attaching on legacy blog series pages.

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

Comment on lines +14 to +37
const getBlogTitle = (collectionItem: HTMLElement): string =>
collectionItem
.querySelector('.usa-collection__heading a')
?.textContent?.trim() || '_ERROR_';

const blogSeriesListClickHandler =
(collectionItems: HTMLElement[]) =>
(evt: Event): void => {
const target = evt.currentTarget as HTMLElement;
const collectionItem = target.closest(
COLLECTION_ITEM_SELECTOR
) as HTMLElement;

if (!collectionItem) {
return;
}

const collectionItemIndex = collectionItems.indexOf(collectionItem);

trackOther(BLOG_SERIES_LIST_EVENT_NAME, BLOG_SERIES_LIST_EVENT_NAME, {
location: 'Body',
componentType: 'Blog Series List',
title: getBlogTitle(collectionItem).slice(0, 50),
linkArea: 'Title',
@dlescarbeau
dlescarbeau force-pushed the ticket/5278-blog-series-list-analytics branch 2 times, most recently from 1469be3 to 06d2166 Compare July 2, 2026 15:22
@dlescarbeau
dlescarbeau marked this pull request as ready for review July 2, 2026 15:23
Closes #5278

update for 5278 commit

updates analytics per copilot feedback
@dlescarbeau
dlescarbeau force-pushed the ticket/5278-blog-series-list-analytics branch from 06d2166 to 1b9f733 Compare July 2, 2026 15:23
@cgdp-management-server

Copy link
Copy Markdown

ODE Deployment

Code has been deployed to ODE 1152.

@davisaw

davisaw commented Jul 7, 2026

Copy link
Copy Markdown

@dlescarbeau Blog Series List Clicks and Blog Pager Clicks both look good!
Just one thing on archive box clicks, the link text includes the year and number of posts e.g. 2018(8). Is it possible to just grab the year? e.g. 2018

- adds tracking to blog categories

- adds tracking to blog archive box

Closes #5279
@dlescarbeau
dlescarbeau force-pushed the ticket/5278-blog-series-list-analytics branch from 1b9f733 to e27c2cd Compare July 7, 2026 17:51
@dlescarbeau

Copy link
Copy Markdown
Contributor Author

@dlescarbeau Blog Series List Clicks and Blog Pager Clicks both look good! Just one thing on archive box clicks, the link text includes the year and number of posts e.g. 2018(8). Is it possible to just grab the year? e.g. 2018

This is being addressed

@andyvanavery31
andyvanavery31 removed their request for review July 7, 2026 20:04

@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, thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

6 participants