Content recommendation widgets are designed to suggest related content to users based on their browsing history and other factors. However, one of the challenges with content recommendation widgets is preventing duplication of content.
When content is duplicated, users may see the same or very similar content repeatedly, which can be frustrating and reduce engagement with the website.
In some cases, there is a risk that a Content recommendation widget or module will show content that is already present on the page. This might occur in different use cases, the most common are described below each paired with details on how to prevent duplication of content in content recommendation widgets.
1. Editorial content is placed close to a deployed module, risking that the same article is shown twice. To avoid this, the script which deploys the widget needs to be instrumented with either document or article IDs which should not be present. This can be done using the "neighbors" and "neighborRemovalKeys" parameters in the context. Please note that at least one of the removal keys must be returned in the widget result to enable removal. See /public/widget/data for more details. Sample code snippets:
cX.CCE.run({ widgetId : '<widget id>',
targetElementId : '<div id>'},
{ context: { neighbors: ['articleid1', 'articleid2']}});
cX.CCE.run({ widgetId : '<widget id>',
targetElementId : '<div id>'},
{ context: { neighbors: ['document_id1', 'document_id2']}});
Using a different removal key:
cX.CCE.run({ widgetId : '<widget id>',
targetElementId : '<div id>'},
{ context: { neighborRemovalKeys: ['my_special_recs_field'], neighbors: ['value1', 'value2']}});
2. Two modules placed on the same page. This scenario is supported by the function cX.CCE.runMulti. Each "widget" object you pass in can have up to 3 fields: "widgetParams", "widgetContext" and "widgetCallback", the same 3 arguments you would normally pass in a cX.CCE.run call. Sample code:
widgets = [];
widgets.push({
widgetParams: {
widgetId: '<widget id>',
targetElementId: '<div id>'
}
});
widgets.push({
widgetParams: {
widgetId: '<widget id>',
targetElementId: '<div id>'
}
});
cX.CCE.callQueue.push(['runMulti', widgets, true]);
Alternatively, use a different removal key:
widgets = [];
widgets.push({
widgetParams: {
widgetId: '<widget id>',
targetElementId: '<div id>'
}
});
widgets.push({
widgetParams: {
widgetId: '<widget id>',
targetElementId: '<div id>'
}
});
cX.CCE.callQueue.push(['runMulti', widgets, 'my_special_recs_field']);
Or, use multiple keys, where each field will be matched one by one until a duplicate is found:
widgets = [];
widgets.push({
widgetParams: {
widgetId: '<widget id>',
targetElementId: '<div id>'
}
});
widgets.push({
widgetParams: {
widgetId: '<widget id>',
targetElementId: '<div id>'
}
});
cX.CCE.callQueue.push(['runMulti', widgets, ['my_special_recs_field1', 'recs-articleid']]);
3. Use cases 1. and 2. combined. Two modules on the same page AND editorial content placed close to those modules. Use that same function cX.CCE.runMulti and additionally pass neighbors as the last argument to it.
widgets = [];
widgets.push({
widgetParams: {
widgetId: '<widget id>',
targetElementId: '<div id>'
}
});
widgets.push({
widgetParams: {
widgetId: '<widget id>',
targetElementId: '<div id>'
}
});
cX.CCE.callQueue.push(['runMulti', widgets, true, ['articleid1', 'articleid2']]);