Hi
I need to pass a custom context Array with every link click.
Looking at - https://github.com/snowplow/snowplow/wiki/2-Specific-event-tracking-with-the-Javascript-tracker#link-click-tracking , it says “enableLinkClickTracking can also be passed an array of custom contexts to attach to every link click event as an additional final parameter. See Contexts for more information .”
But there is no explanation how to do that.
What is the right way to add a custom context?
Thx
Ziv
mike
June 18, 2018, 5:59am
2
It looks like that function definition doesn’t include contexts
even though the functionality has been there for quite a while.
* by either click handler. The workaround is to set a target attribute (which can't
* be "_self", "_top", or "_parent").
*
* @see https://bugs.webkit.org/show_bug.cgi?id=54783
*
* @param object criterion Criterion by which it will be decided whether a link will be tracked
* @param bool pseudoClicks If true, use pseudo click-handler (mousedown+mouseup)
* @param bool trackContent Whether to track the innerHTML of the link element
* @param array context Context for all link click events
*/
enableLinkClickTracking: function (criterion, pseudoClicks, trackContent, context) {
if (mutSnowplowState.hasLoaded) {
// the load event has already fired, add the click listeners now
linkTrackingManager.configureLinkClickTracking(criterion, pseudoClicks, trackContent, context);
linkTrackingManager.addClickListeners();
} else {
// defer until page has loaded
mutSnowplowState.registeredOnLoadHandlers.push(function () {
linkTrackingManager.configureLinkClickTracking(criterion, pseudoClicks, trackContent, context);
linkTrackingManager.addClickListeners();
});
The last parameter will allow you to pass in an array of contexts e.g.,
window.snowplow('enableLinkClickTracking', null, true, true,
[{
schema: 'iglu:com.acme/link_click/jsonschema/1-0-0',
data: {
'click_id': 1234
}
}]
);
Thx a lot Mike!
Will try it out