The ActivityMap.link
variable allows you to override the logic that Activity Map uses to set link values. This variable is useful in areas where you want to have more control than what ActivityMap.linkExclusions
provides.
This variable completely overrides Activity Map logic. Setting an override function here that returns incorrect values can cause data collection issues with Activity Map dimensions and the Activity Map overlay.
You can use OnBeforeLinkClickSend
callback to alter the Web SDK payload or abort sending data.
There is not a dedicated field in the Adobe Analytics extension to use this variable. Use the custom code editor, following AppMeasurement syntax.
Assign this variable a function that:
If the return value is falsy, all Activity Map context data variables are cleared and no link data is tracked.
Only use the title attribute from <a>
tags. If the title attribute is not present, no link is tracked.
s.ActivityMap.link = function(clickedElement) {
var linkId;
if (clickedElement && clickedElement.tagName.toUpperCase() === 'A') {
linkId = clickedElement.getAttribute('title');
}
return linkId;
}
Return the manually set link name in s.tl
if it exists, otherwise return the link URL.
s.ActivityMap.link = function(ele, linkName) {
if (linkName) {
return linkName;
}
if (ele && ele.tagName == 'A' && ele.href) {
return ele.href;
}
}
Instead of completely replacing the default link logic, you can conditionally alter it.
<script>
// Copy the original link function
var originalLinkFunction = s.ActivityMap.link;
// Return the link name from s.tl, a modified activity map value, or the original activity map value
s.ActivityMap.link = function(element,linkName)
{
return linkName || customFunction(element) || originalLinkFunction(element,linkName);
};
</script>
<button type="button" onclick="s.tl(this,'o',customFunction(this)">Add To Cart</button>
linkName
is passed, then the method was called by tl()
. Return what tl()
passed in as linkName
.linkName
is never passed, so call customFunction()
with the link element. You can use any custom function that you’d like to return a value.