Skip to content
This repository has been archived by the owner on Nov 13, 2023. It is now read-only.

Commit

Permalink
feat: track hemingway info on click events
Browse files Browse the repository at this point in the history
  • Loading branch information
ramboz committed Aug 1, 2023
1 parent 70b61f3 commit bf305d3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions express/scripts/instrument.js
Original file line number Diff line number Diff line change
Expand Up @@ -1260,6 +1260,7 @@ loadScript(martechURL, () => {
hemingway: {
assetId: evt.assetId,
assetPath: evt.assetPath,
assetPosition: evt.assetPosition,
},
},
},
Expand Down
4 changes: 4 additions & 0 deletions express/scripts/scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,10 +129,14 @@ function trackViewedAssetsInDataLayer(assetsSelector = 'img[src*="/media_"]') {
assetPath = new URL(assetPath).pathname;
const match = assetPath.match(/media_([a-f0-9]+)\.\w+/);
const assetFilename = match ? match[0] : assetPath;
const siblings = el.className
? [...el.closest('.block').querySelectorAll(`.${el.className.split(' ').join('.')}`)]
: [];
const details = {
event: 'viewasset',
assetId: assetFilename,
assetPath,
assetPosition: siblings.indexOf(el),
};

// Add experiment details
Expand Down

0 comments on commit bf305d3

Please sign in to comment.