From 9cbf2b4195f9f8aa7749310862bc6354f6e4a0c4 Mon Sep 17 00:00:00 2001 From: Mauricio Ochoa Date: Thu, 26 Dec 2024 20:10:44 -0500 Subject: [PATCH] Enhance CTA tracking by identifying block names and their indices --- scripts/scripts.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/scripts/scripts.js b/scripts/scripts.js index 57c042b..0f202d4 100644 --- a/scripts/scripts.js +++ b/scripts/scripts.js @@ -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; } }