Expand my Community achievements bar.

SOLVED

Link tracking not tracking text of the link in Link Name

Avatar

Level 2

hi 

 

I am using Web SDK and in weblinks calls, the link name is always "Link Click" and it doesn't capture the text of the link clicked. 

 

Thanks

Parm

1 Accepted Solution

Avatar

Correct answer by
Level 4

Hi,

 

Link name maps to web.webInteraction.name in your xdm object. If you have got that part correct, then the issue seems more about how you are capturing the link name from website, are you using vanilla javaScript 'this' keyword, or jQuery $(this). Will suggest to first test this traditionally without using web sdk.

 

Refer to the below code for the field where you have to map link names. 

alloy("sendEvent", {
  "xdm": {
    "web": {
      "webInteraction": {
        "name": "My Custom Link",
        "URL": "https://example.com",
        "type": "other"
      }
    }
  }
});

 

If you are using Tags (Launch) UI, go to data elements, select XDM object and map in the below field

V_Sirish_Kaushik1_0-1688062928794.png


Please refer to below documentation for more clarity 

https://experienceleague.adobe.com/docs/platform-learn/implement-web-sdk/applications-setup/setup-an...

 

View solution in original post

3 Replies

Avatar

Level 5

1. Review the code responsible for capturing the link clicks and check if it needs any modifications. Make sure you are capturing the correct information from the clicked link. It's possible that the code is not correctly extracting the text from the link element.

Like, To validate the selectors (Id, class) whether all the values are expected, example code

// Add an event handler to capture link clicks
$(document).on('click', 'a', function(event) {
event.preventDefault(); // Prevent the default link behavior
var linkText = $(this).text(); // Extract the text of the clicked link
// Store the link text in a dynamic variable or use it as needed
// For example, you can send it to Adobe Analytics or display it on the page
// Here, we're just logging it to the console as an example
console.log('Clicked link text:', linkText);
});

2. Ensure that you have properly configured the Adobe Web SDK and have set up the link tracking correctly. Double-check the code and configuration settings related to link tracking to ensure they are properly implemented.

 

 

Avatar

Community Advisor

If you're using Tags, and assuming that you're detecting the clicks from its Core extension's Click event, then here's a shortcut to get the text of the clicked link: use "this.@cleanText" in your Web SDK webInteraction field's value, i.e.

alloy("sendEvent", {
  "xdm": {
    "web": {
      "webInteraction": {
        "linkClicks": {
            "value": 1
        },
        "name": this.@cleanText,
        "URL": this.href,
        "type": "other" // values: other, download, exit
      }
    }
  }
});

Avatar

Correct answer by
Level 4

Hi,

 

Link name maps to web.webInteraction.name in your xdm object. If you have got that part correct, then the issue seems more about how you are capturing the link name from website, are you using vanilla javaScript 'this' keyword, or jQuery $(this). Will suggest to first test this traditionally without using web sdk.

 

Refer to the below code for the field where you have to map link names. 

alloy("sendEvent", {
  "xdm": {
    "web": {
      "webInteraction": {
        "name": "My Custom Link",
        "URL": "https://example.com",
        "type": "other"
      }
    }
  }
});

 

If you are using Tags (Launch) UI, go to data elements, select XDM object and map in the below field

V_Sirish_Kaushik1_0-1688062928794.png


Please refer to below documentation for more clarity 

https://experienceleague.adobe.com/docs/platform-learn/implement-web-sdk/applications-setup/setup-an...