ActivityMap.link
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.
Overriding link values using the Web SDK
You can use OnBeforeLinkClickSend
callback to alter the Web SDK payload or abort sending data.
Link override using the Adobe Analytics extension
There is not a dedicated field in the Adobe Analytics extension to use this variable. Use the custom code editor, following AppMeasurement syntax.
ActivityMap.link in AppMeasurement and the Analytics extension custom code editor
Assign this variable a function that:
- Receives the HTML element that was clicked; and
- Returns a string value. This string value is the final value used for the Activity Map Link dimension.
If the return value is falsy, all Activity Map context data variables are cleared and no link data is tracked.
Examples
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>
- If
linkName
is passed, then the method was called bytl()
. Return whattl()
passed in aslinkName
. - When called by Activity Map, a
linkName
is never passed, so callcustomFunction()
with the link element. You can use any custom function that you’d like to return a value. - If neither of the above return values, use the link name normally collected as a fallback.