enableLinkClickTracking Filter functions not working

Hi, I am trying to filter those link which I don’t want to track by using filter function but it’s track all the link without filtering. I also trying to log that function is calling or not but found that it’s not call this function. Please find below the code snippet.

//MY CUSTOM FILTER FOR FILTERING SPECIFIC URL
function myCustomFilter(linkElement) {
        console.log(linkElement);
        return linkElement.href !== 'google';
}

//ENABLE LINK CLICK FOR SPECIFIC URLs
snowplow('enableLinkClickTracking', {
      options: { filter: myCustomFilter }
});

Anyone please help me with this issue.

Thanks in Advance

@PawanK , did you mean

!linkElement.href.includes('google')

Also bear in mind that enableLinkClickTracking has to execute after the links are rendered by the browser (in case you have dynamic links).

1 Like

Hi @ihor,

Thanks for the update, I checked that but no luck to solve it :frowning:

In Network tab I always see that snowplow link click event is fired in every case.

Hey @PawanK :slight_smile:
Can you provide us a CodeSandbox or something similar (example repo) where you can reproduce the issue ?

Hey @Peter_Perlepes,

Thanks for the update, please find below the URL where we have added snowplow tag :

Website URL : https://layer-5.myshopify.com/

Actually, I don’t want to track those URL which is internal, I want to track only external URL.

Please find below code syntax, which I have used in aforesaid url.

//MY CUSTOM FILTER FOR FILTERING SPECIFIC URL
function myCustomFilter(linkElement) {
        return !linkElement.href.includes('layer-5.myshopify.com');
}
//ENABLE LINK CLICK FOR SPECIFIC URLs
window.l5plow('enableLinkClickTracking', { options: { 'filter': myCustomFilter }});

@ihor, @Peter_Perlepes could you please help me for the same, or guide me what I missed in above please…

Thanks in Advance

@PawanK , as I can see you are using the older version of the tracker, v2.12. The usage of enableLinkClickTracking is different for that version. Please, refer to Tracking Events | Snowplow Documentation for guidance instead.

In particular, your tracking code would look like below:

window.l5plow('enableLinkClickTracking', {'filter': myCustomFilter});