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.

CAUTION
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:

  • 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>
  1. If linkName is passed, then the method was called by tl(). Return what tl() passed in as linkName.
  2. When called by Activity Map, a 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.
  3. If neither of the above return values, use the link name normally collected as a fallback.
recommendation-more-help
b4f6d761-4a8b-4322-b801-c85b9e3be690