Skip to content

Commit

Permalink
Take matomo site id into consideration
Browse files Browse the repository at this point in the history
  • Loading branch information
tiberiuichim committed Dec 2, 2020
1 parent 8c3c109 commit cac84c1
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,26 @@ const _matomo = {};
const doWithMatomo = (fn) => {
if (__CLIENT__) {
if (!_matomo.instance) {
const siteId =
window.env?.RAZZLE_MATOMO_SITE_ID || settings.matomoSiteId || 1;
const siteId = window.env?.RAZZLE_MATOMO_SITE_ID || settings.matomoSiteId;

const urlBase =
window.env?.RAZZLE_MATOMO_URL ||
settings.matomoUrlBase ||
'https://matomo.eea.europa.eu/';

_matomo.instance = createInstance({
urlBase,
siteId,
});
if (siteId) {
_matomo.instance = createInstance({
urlBase,
siteId,
});
} else {
console.warn(
'Matomo SiteID is not defined, page actions will not be tracked',
);
}
}

fn(_matomo.instance);
if (_matomo.instance) fn(_matomo.instance);
}
};

Expand Down

0 comments on commit cac84c1

Please sign in to comment.