Charlotta Öijer Thalén

Possible to replace Content of Link Clicks in the JavaScript tracker?

With Button Clicks it is possible to override the label of the button by adding a "data-sp-button-label" attribute, has anybody achieved the same functionality for Link Clicks, overriding content?
I can't find that the same functionality is built in but perhaps I can do it by setting trackContent to false and add the content via a custom entity?
Any experiences and/or ideas are highly appreciated.

2 1 2
Yorgos Koliopoulos
Hi Charlotta,
 
The trackContent option is by default set to false. Unless you explicitly set this to true, the content of the link won't be tracked.There are two options you could utilise to add custom attributes to the link click event.
  • You can pass an array of custom context entities to attach to every link click event as an additional final parameter. In JavaScript tracker that would look like:
let dynamicContext = function (element) { 
// perform operations here to construct the context
return context;
};

snowplow('enableLinkClickTracking', { context: [dynamicContext] });
You can find details on how to construct the custom context in our documentation page here.
  • Manually track individual link click events with the trackLinkClick method. You can read more about this in our documentation page here.
Another possible solution would be to enable the JavaScript enrichment where you can write your own JS code to modify the elementContent field of the link click event (if tracking it, is enabled).