It's probably because Buttons don't trigger Activity Map by default?
I had to add some modified code to get it to read buttons.... I don't actually use the s_objectID.. but in theory if you can get the Activity Map to read button elements, this should then work??
Unless of course modifying the Activity Map link detection breaks s_objectID....
Basically, I used
https://experienceleague.adobe.com/docs/analytics/analyze/activity-map/link-tracking/activitymap-lin...
to modify the s.ActivityMap.link
The example code is:
// only ever use "title" attributes from A tags
function(clickedElement) {
var linkId;
if (clickedElement && clickedElement.tagName.toUpperCase() === 'A') {
linkId = clickedElement.getAttribute('title');
}
return linkId;
}
Where you can see that in this case, they are over-writing the linkID with the title attribute, instead of the innerText...
In my case, I added a check for
clickedElement.tagName.toUpperCase() === 'BUTTON'
And created some additional checks for content...
- pulling from a custom data attribute if it exists
- then if not, looking at the innerText
- then if nothing looking there, if the child element was an image and pulling the alt text of the image
- then if that failed pulling from the title attribute
- then if still nothing pulling from the id
- then finally failing all of that, pulling from the class
Basically, as I discovered different variants on our sites that didn't get a linkId (meaning Activity Map didn't track them) I added variations to check... most of out links fall into the first three items... I rarely see the other logic, but I left it in place to be safe.....