function FluidbookStats() {
this.hasMatomoTagManager = this.setupMatomoTagManager();
this.pixel_pv_id;
+ this.user_id = window.MATOMO_USER_ID !== undefined ? window.MATOMO_USER_ID : window.sessionStorage.getItem('secureUsername');
this.matomo_stack = [];
this.setupMatomo();
}
if (SETTINGS.statsMatomoServer === undefined || SETTINGS.statsMatomoServer === null) {
SETTINGS.statsMatomoServer = '3';
}
+ let pixel = this.hasMatomoTagManager || SETTINGS.matomoTracking === 'pixel' || SETTINGS.matomoTracking === 'proxy' ? this.getPixelUUID() : false;
this.matomoServers.push({
server: 'stats' + SETTINGS.statsMatomoServer + '.fluidbook.com',
siteId: SETTINGS.statsMatomo,
referer: '',
fullURL: false,
mtm: false,
- pixel: this.hasMatomoTagManager ? this.getPixelUUID() : false,
+ pixel: pixel,
+ pixelProxy: SETTINGS.matomoTracking === 'proxy',
});
}
if (SETTINGS.matomoServer && SETTINGS.matomoSiteId && !this.hasMatomoTagManager) {
referer: '',
fullURL: true,
mtm: false,
+ pixel: SETTINGS.matomoTracking === 'pixel' || SETTINGS.matomoTracking === 'proxy' ? this.getPixelUUID() : false,
+ pixelProxy: SETTINGS.matomoTracking === 'proxy',
});
}
- if (this.matomoServers.length > 0 && !this.hasMatomoTagManager) {
+
+ if (this.matomoServers.length > 0 && !this.hasMatomoTagManager && SETTINGS.matomoTracking !== 'pixel' || SETTINGS.matomoTracking !== 'proxy') {
let u = 'https://' + this.matomoServers[0].server + '/';
window._paq = window._paq || [];
- if (window.MATOMO_USER_ID !== undefined) {
- window._paq.push(['setUserId', window.MATOMO_USER_ID]);
+ if (this.user_id !== null) {
+ window._paq.push(['setUserId', this.user_id]);
}
window._paq.push(["setDoNotTrack", true]);
window._paq.push(['enableHeartBeatTimer']);
matomoSetCartItems: function (items) {
for (var i in items) {
let item = items[i];
- this.matomoPush(['addEcommerceItem',
- item.reference, // (Required) productSKU
+ this.matomoPush(['addEcommerceItem', item.reference, // (Required) productSKU
item.name, // (Optional) productName
item.categories, // (Optional) productCategory
item.price, // (Recommended) price
- item.quantity
- ]);
+ item.quantity]);
}
},
}
url += '&res=' + screen.width + 'x' + screen.height;
if (data[0] === 'trackPageView') {
- url += '&action_name=' + data[1];
+ url += '&action_name=' + encodeURIComponent(data[1]);
this.pixel_pv_id = this.generatePixelPVID();
} else if (data[0] === 'trackSiteSearch') {
url += '&search=' + encodeURIComponent(data[1]);
url += '&e_' + order[i - 1] + '=' + encodeURIComponent(data[i]);
}
}
+ if (this.user_id !== null) {
+ url += '&uid=' + encodeURIComponent(this.user_id);
+ }
url += '&pv_id=' + this.pixel_pv_id;
+
+ if (server.pixelProxy) {
+ url = 'https://toolbox.fluidbook.com/s/prxtm?d=' + btoa(url);
+ }
+
let i = new Image();
i.src = url;
return;