Last active
August 9, 2022 12:07
-
-
Save yuhui/63916a34327134da146f58b6e91b9025 to your computer and use it in GitHub Desktop.
Adobe Analytics: Specify new functions that Adobe Analytics' Analytics Map should use for tracking links and regions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// update Activity Map to determine how to get its region and link | |
s.ActivityMap.originalRegion = s.ActivityMap.region; | |
s.ActivityMap.region = function(element) { | |
if (element) { | |
// set the region based on the element's (or ancestor's) "data-section-id" attribute | |
var currentElement = element; | |
var sectionId = currentElement.getAttribute('data-section-id'); | |
while (!sectionId && (currentElement = currentElement.parentElement)) { | |
sectionId = currentElement.getAttribute('data-section-id'); | |
} | |
return sectionId || s.ActivityMap.originalRegion(element); | |
} | |
}; | |
s.ActivityMap.originalLink = s.ActivityMap.link; | |
s.ActivityMap.link = function(element, linkName) { | |
if (element) { | |
// set the link based on the element's "data-link-title" attribute | |
return element.getAttribute('data-link-title') || s.ActivityMap.originalLink(element, linkName); | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment