-function FluidbookStats(fluidbook) {
- var $this = this;
- this.fluidbook = fluidbook;
- this.id = this.fluidbook.settings.id;
- this.vid = guid();
- this.relay_url_params = '';
- this.lastTCHash = '';
- this.gaqueue = [];
- this.baseURL = trim((window.location.origin + window.location.pathname).replace("index.html", ""), '/');
-
- this.matomoServers = [];
- if (this.fluidbook.settings.statsMatomo) {
- if (this.fluidbook.settings.statsMatomoServer === undefined || this.fluidbook.settings.statsMatomoServer === null) {
- this.fluidbook.settings.statsMatomoServer = '3';
- }
- this.matomoServers.push({
- server: 'stats' + this.fluidbook.settings.statsMatomoServer + '.fluidbook.com',
- siteId: this.fluidbook.settings.statsMatomo,
- lastURL: '',
- referer: '',
- fullURL: false,
- });
- }
- if (this.fluidbook.settings.matomoServer && this.fluidbook.settings.matomoSiteId) {
- this.matomoServers.push({
- server: this.fluidbook.settings.matomoServer,
- siteId: this.fluidbook.settings.matomoSiteId,
- lastURL: '',
- referer: '',
- fullURL: true
- });
- }
+function FluidbookStats() {
+ this.setupMatomo();
+}
- if ($_GET['puppeteer'] !== undefined) {
- this.fluidbook.settings.stats = false;
- this.fluidbook.settings.googleTagManager = '';
- this.fluidbook.settings.googleAnalytics = '';
- this.fluidbook.settings.statsMatomo = false;
- this.fluidbook.settings.tagcommander_id = '';
- this.fluidbook.settings.xiti = '';
- this.fluidbook.settings.tagcommander_plan_type = '';
+FluidbookStats.prototype = {
+ setupMatomo: function () {
this.matomoServers = [];
- }
+ if (SETTINGS.statsMatomo) {
+ if (SETTINGS.statsMatomoServer === undefined || SETTINGS.statsMatomoServer === null) {
+ SETTINGS.statsMatomoServer = '3';
+ }
+ this.matomoServers.push({
+ server: 'stats' + SETTINGS.statsMatomoServer + '.fluidbook.com',
+ siteId: SETTINGS.statsMatomo,
+ lastURL: '',
+ referer: '',
+ fullURL: false,
+ });
+ }
+ if (SETTINGS.matomoServer && SETTINGS.matomoSiteId) {
+ this.matomoServers.push({
+ server: SETTINGS.matomoServer,
+ siteId: SETTINGS.matomoSiteId,
+ lastURL: '',
+ referer: '',
+ fullURL: true
+ });
+ }
- if (this.fluidbook.settings.tagcommander_plan_type === 'esm') {
- this.esm = new FluidbookStatsEsm(this.fluidbook);
- }
- if (this.fluidbook.settings.stats) {
- this.worker = new Worker('js/libs/fluidbook/workers/stats.js');
- }
- if (this.matomoServers.length > 0) {
- let u = 'https://' + this.matomoServers[0].server + '/';
- window._paq = window._paq || [];
- window._paq.push(["setDoNotTrack", true]);
- window._paq.push(['enableHeartBeatTimer']);
- window._paq.push(['enableLinkTracking']);
- if (this.matomoServers.length === 1) {
- window._paq.push(['setTrackerUrl', 'https://' + this.matomoServers[0].server + '/matomo.php']);
- window._paq.push(['setSiteId', this.matomoServers[0].siteId]);
+ if (this.matomoServers.length > 0) {
+ let u = 'https://' + this.matomoServers[0].server + '/';
+ window._paq = window._paq || [];
+ window._paq.push(["setDoNotTrack", true]);
+ window._paq.push(['enableHeartBeatTimer']);
+ window._paq.push(['enableLinkTracking']);
+ window._paq.push(['enableJSErrorTracking']);
+ if (this.matomoServers.length === 1) {
+ window._paq.push(['setTrackerUrl', 'https://' + this.matomoServers[0].server + '/matomo.php']);
+ window._paq.push(['setSiteId', this.matomoServers[0].siteId]);
+ }
+ var d = document, g = d.createElement('script'), s = d.getElementsByTagName('script')[0];
+ g.async = true;
+ g.src = u + 'matomo.js';
+ s.parentNode.insertBefore(g, s);
}
- var d = document, g = d.createElement('script'), s = d.getElementsByTagName('script')[0];
- g.async = true;
- g.src = u + 'matomo.js';
- s.parentNode.insertBefore(g, s);
- }
- if (this.fluidbook.settings.googleTagManager !== undefined && this.fluidbook.settings.googleTagManager !== '') {
- this.ga = 'gtm';
- } else if (this.fluidbook.settings.googleAnalytics !== '') {
- this.ga = 'gtag';
- this.gaCodes = this.fluidbook.settings.googleAnalytics.split(',');
- if (window.gtag !== undefined) {
- gtag('js', new Date());
+ },
+
+ setup: function (fluidbook) {
+ var $this = this;
+ this.fluidbook = fluidbook;
+ this.id = this.fluidbook.settings.id;
+ this.vid = guid();
+ this.relay_url_params = '';
+ this.lastTCHash = '';
+ this.gaqueue = [];
+ this.baseURL = trim((window.location.origin + window.location.pathname).replace("index.html", ""), '/');
+
+ if ($_GET['puppeteer'] !== undefined) {
+ this.fluidbook.settings.stats = false;
+ this.fluidbook.settings.googleTagManager = '';
+ this.fluidbook.settings.googleAnalytics = '';
+ this.fluidbook.settings.statsMatomo = false;
+ this.fluidbook.settings.tagcommander_id = '';
+ this.fluidbook.settings.xiti = '';
+ this.fluidbook.settings.tagcommander_plan_type = '';
+ this.matomoServers = [];
+ }
+
+ if (this.fluidbook.settings.tagcommander_plan_type === 'esm') {
+ this.esm = new FluidbookStatsEsm(this.fluidbook);
}
- $.each(this.gaCodes, function (k, code) {
+ if (this.fluidbook.settings.stats) {
+ this.worker = new Worker('js/libs/fluidbook/workers/stats.js');
+ }
+
+ if (this.fluidbook.settings.googleTagManager !== undefined && this.fluidbook.settings.googleTagManager !== '') {
+ this.ga = 'gtm';
+ } else if (this.fluidbook.settings.googleAnalytics !== '') {
+ this.ga = 'gtag';
+ this.gaCodes = this.fluidbook.settings.googleAnalytics.split(',');
if (window.gtag !== undefined) {
- gtag('config', code, {'send_page_view': false});
+ gtag('js', new Date());
}
- });
- if (this.fluidbook.settings.gtag_additional_code !== '') {
- eval(this.fluidbook.settings.gtag_additional_code);
- }
- } else {
- this.checkGoogleAnalytics();
- }
- if (this.fluidbook.settings.relay_url_params !== '') {
- var e = this.fluidbook.settings.relay_url_params.split(',');
- var p = [];
- $.each(e, function (k, v) {
- v = v.trim();
- if ($_GET[v] !== undefined && $_GET[v] !== null) {
- p.push(v + '=' + encodeURIComponent($_GET[v]));
+ $.each(this.gaCodes, function (k, code) {
+ if (window.gtag !== undefined) {
+ gtag('config', code, {'send_page_view': false});
+ }
+ });
+ if (this.fluidbook.settings.gtag_additional_code !== '') {
+ eval(this.fluidbook.settings.gtag_additional_code);
}
- });
- this.relay_url_params = p.join('&');
- }
- this.init();
-}
+ } else {
+ this.checkGoogleAnalytics();
+ }
+ if (this.fluidbook.settings.relay_url_params !== '') {
+ var e = this.fluidbook.settings.relay_url_params.split(',');
+ var p = [];
+ $.each(e, function (k, v) {
+ v = v.trim();
+ if ($_GET[v] !== undefined && $_GET[v] !== null) {
+ p.push(v + '=' + encodeURIComponent($_GET[v]));
+ }
+ });
+ this.relay_url_params = p.join('&');
+ }
+
+ this.init();
+ },
-FluidbookStats.prototype = {
init: function () {
var $this = this;
$(document).on(this.fluidbook.input.clickEvent, 'a[data-track]', function () {