Expand my Community achievements bar.

Regarding the Activity Map, it is possible to retrieve the href value of the link

Avatar

Level 2

Hello, we are using Activity Map, and when clicking on a CTA, we want it to capture the href value of the link rather than the button's name. We have employed a dataElement with the Activity Map customizer extension, but it retrieves the entire URL, and we need to exclude parameters from the button's URL. Is it possible to achieve this? Thank you.

Screenshot_1.png

3 Replies

Avatar

Community Advisor

It should be possible.. but full disclosure, I've never used this extension...

 

I have done all my Activity Map customizations via code in the Analytics extension custom code area....

 

https://experienceleague.adobe.com/docs/analytics/analyze/activity-map/link-tracking/activitymap-lin...

 

So basically, I modified our tracking to take the link name from links, the button text from buttons, and the alt text from images wrapped in anchor tags (where there was no "link text").

 

Starting with the basic code:

 

s.ActivityMap.link = function(clickedElement) {
  var linkId;
  if (clickedElement && clickedElement.tagName.toUpperCase() === 'A') {
    // This will take the "title attribute"
    linkId = clickedElement.getAttribute('title');
  }
  return linkId;
}

 

 

Obviously, this isn't what you want, but you should be able to take the href attribute instead of the title...

 

 

 

You can then add some JS to remove parameters if they exist, something like:

 

s.ActivityMap.link = function(clickedElement) {
  var linkId;
  if (clickedElement && clickedElement.tagName.toUpperCase() === 'A') {
    // This will take the "href attribute"
    linkId = clickedElement.getAttribute('href');
    if (linkId && linkId.indexOf('?') > -1){
      linkId = linkId.substr(0, linkId.indexOf('?'));
    }
  }
  return linkId;
}

 

 

 

This can just be added to the top of the custom code in your extension, it does not need to be called in s_doPlugins.

 

When the Analytics script is loaded, this code will run and manipulate how Activity Map reads the clicked elements.

 

You will want to test this obviously, and maybe make additional tweaks to the code.

Avatar

Level 2

Hi Jennifer,

Thank you very much for your reply.
Unfortunately, the solution cannot be applied as it overwrites the original function found in Adobe Analytics, i.e. it modifies the functionality of the extension. We are trying to create a code where a new dataElement is created that calls the functionality of the Adobe Analytics extension and removes the parameters from the URL.
Any help is welcome.
Thanks

Avatar

Community Advisor

You can attempt to use the s_object attribute on your buttons.. someone else was having issues with this, but it may have been specific to other parts of their implementation...

 

https://experienceleague.adobe.com/docs/analytics/implementation/vars/page-vars/s-objectid.html?lang...

 

 

This will of course require your developers to add this attribute to all of the elements that you need modified.