Skip to content

Commit

Permalink
Enhance CTA tracking by identifying block names and their indices
Browse files Browse the repository at this point in the history
  • Loading branch information
Mao8a committed Dec 27, 2024
1 parent 5dd770e commit 9cbf2b4
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion scripts/scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,14 @@ function instrumentTrackingEvents(main) {
trackCTAEvent(ctaLocation);
return;
} else {
trackCTAEvent(null);
const containerBlock = e.target.closest('[data-block-name]');
const blockList = document.querySelectorAll(`[data-block-name=${containerBlock.dataset.blockName}]`);
blockList.forEach((block, key) => {
if (block === containerBlock) {
ctaLocation = `${containerBlock.dataset.blockName}_${key}`;
}
});
trackCTAEvent(ctaLocation);
return;
}
}
Expand Down

0 comments on commit 9cbf2b4

Please sign in to comment.