Expand my Community achievements bar.

Recommendations Click Metric not Tracking

Avatar

Level 2

The out-of-the-box metric for click tracking on our product recommendations is not coming through in Target.

As an attempted stop gap we created a custom event and added it through Launch, hoping to capture the clicks that way but have been unsuccessful.

So, here's my question, what does the event look like from a script perspective if we wanted to include it as a piece of code that is hard coded in a launch rule?

This is the code I am currently using to try and replicate the recommendation click that is available out of the box. Still, I am missing something and haven't been able to find documentation about what should fire on the click of a recommendation.

var clickType = 'Recommendations';
var pageType = window.digitalData.page.type;
var pageSection = window.digitalData.page.section;
var pageName = window.digitalData.page.pageName;
var pageCategory = window.digitalData.page.browseCategory;
var pageUrl = window.location.href;
var recProductsTitle = document.querySelector('[offers-header] h2').innerText;

var recProducts = document.querySelectorAll('[offer] a');
var recProductNames = document.querySelectorAll('[offer--product-name]');
[].forEach.call(recProducts, function (item, index) {
    var recProductName = recProductNames[index].innerText;
    item.addEventListener('click', (e) => {
        adobe.target.trackEvent({"mbox": "pdp_recommend_display","params": {
            "clickType": clickType,
            "recommendationsTitle": recProductsTitle,
            "productName": recProductName,
            "productCategory": pageCategory,
            "currentURL": pageUrl,
            "pageType": pageType,
            "pageSection": pageSection,
            "pageName": pageName
            }
        });
    });
});

Any help is much appreciated.

0 Replies