This is my code i tried to set the custom variable in Magento but i can’t see any variables is showing in matomo admin panel. I created the new Js file and declared this code into that please any one help me to do this. The situation i need to do is if the customer is logged in he need to indicate as customer in custom variable field.
require(["jquery","Henhed_Piwik/js/tracker","Magento_Customer/js/customer-data"], function($,trackerComponent,customerData) {
var customData = customerData.get("customer");
customData.subscribe(function (updatedCustomer){
console.log(updatedCustomer);
console.log(updatedCustomer['piwikUserId']);
trackUserId = updatedCustomer['piwikUserId'];
trackerComponent.getTracker().done(function (tracker) {
if(trackUserId != null){
w._paq.push(['setCustomVariable','1','VisitorType','CUSTOMER']);
w._paq.push(['trackPageView']);
}
console.log( _paq);
});
}, this);
});