Expand my Community achievements bar.

Join us for the next Community Q&A Coffee Break on Tuesday April 23, 2024 with Eric Matisoff, Principal Evangelist, Analytics & Data Science, who will join us to discuss all the big news and announcements from Summit 2024!
SOLVED

Custom code to suppress PII from Activity Map

Avatar

Level 4

I'm tasked with creating a Rule to track the number of instances an email link is clicked, i.e. <a href=malto:somemail@domain.com>somemail@domain.com</a>. Creating a rule is easy enough but this is PII and the issue is that the email address is PII and it must not be collected into any variables including out of the box Activity Map (Activity Map Link) and ClickMap (Object ID) variables.

 

After some research, I was able to successfully suppress them by adding this to the Custom Code in the Analytics Extension in Data Collection:

s.ActivityMap.regionExclusions = '"element_id';

 

Where element_id is the ID of the element container such as div or section or span that contains the email link. Again, this works perfectly and the Rule fires but the email address is nowhere to be found on the hit variables.

 

The issue is that the IDs are inconsistent. I happened to find them by testing and looking at the debugger. But what if there are other IDs I did not add in the exclusion list? This solution falls apart. I will always need the full list of IDs to exclude, which is cumbersome.

 

QUESTION: Is there a way to evaluate the link and look for the @ character. If there's an @ in the link, it's likely an email address. Therefore if it's an email address, suppress it from being collected in Activity Map and Click Map. By doing this I will not rely on knowing all the IDs to exclude and instead check on the fly if it's an email address that was clicked and if so suppress it. 

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

You can provide your own code for ActivityMap to use when it detects a link. In your case, your code would preferably use a regular expression -- or even detecting the "mailto:" protocol -- to detect email links.

Maybe something like this? Note: I haven't tested this code, so you will definitely need to adapt it to your requirements and also to test it properly.

// preserve the original function, e.g. for cases where the link is *not* an email link
s.ActivityMap.originalLink = s.ActivityMap.link;
s.ActivityMap.link = function(element, linkName) {
  if (element) {
    // check for mailto: protocol
    // alternatively, you can provide your own evaluation condition, e.g. using a regular expression to check for an email address
    if (element.protocol && element.protocol === 'mailto:') {
      // this is an email link
      return 'email link'; // this is the ActivityMap link name
    } else {
      // this isn't an email link
      // use ActivityMap's original function
      return s.ActivityMap.originalLink(element, linkName);
    }
  }
};

View solution in original post

2 Replies

Avatar

Correct answer by
Community Advisor

You can provide your own code for ActivityMap to use when it detects a link. In your case, your code would preferably use a regular expression -- or even detecting the "mailto:" protocol -- to detect email links.

Maybe something like this? Note: I haven't tested this code, so you will definitely need to adapt it to your requirements and also to test it properly.

// preserve the original function, e.g. for cases where the link is *not* an email link
s.ActivityMap.originalLink = s.ActivityMap.link;
s.ActivityMap.link = function(element, linkName) {
  if (element) {
    // check for mailto: protocol
    // alternatively, you can provide your own evaluation condition, e.g. using a regular expression to check for an email address
    if (element.protocol && element.protocol === 'mailto:') {
      // this is an email link
      return 'email link'; // this is the ActivityMap link name
    } else {
      // this isn't an email link
      // use ActivityMap's original function
      return s.ActivityMap.originalLink(element, linkName);
    }
  }
};

Avatar

Level 4

I tried your code AS IS and it works perfectly. Mailto links still sends an image request but without the email address. Other clickable elements that are tracked in Activity Map are untouched and works fine. Thank you, your help is much appreciated.