diff --git a/.travis.yml b/.travis.yml index 962357e..c761997 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,6 +3,7 @@ php: - 7.1 - 7.0 env: + - M2_VERSION=2.2.3 - M2_VERSION=2.2.2 - M2_VERSION=2.2.1 - M2_VERSION=2.2.0 diff --git a/view/frontend/web/js/tracker.js b/view/frontend/web/js/tracker.js index 5110991..f5350e4 100644 --- a/view/frontend/web/js/tracker.js +++ b/view/frontend/web/js/tracker.js @@ -288,7 +288,17 @@ define([ } /** - * Initialzie this component with given options + * Checks that piwik.js is already on page + * + * @param {String} scriptUrl + * @returns {boolean} + */ + function scriptExists(scriptUrl) { + return $('script[src="' + scriptUrl + '"]').length === 1; + } + + /** + * Initialize this component with given options * * @param {Object} options */ @@ -296,11 +306,13 @@ define([ defaultSiteId = options.siteId; defaultTrackerUrl = options.trackerUrl; if (piwik === null) { - pushAction([ - ['setSiteId', defaultSiteId], - ['setTrackerUrl', defaultTrackerUrl] - ]); - injectScript(options.scriptUrl); + if (!scriptExists(options.scriptUrl)) { + pushAction([ + ['setSiteId', defaultSiteId], + ['setTrackerUrl', defaultTrackerUrl] + ]); + injectScript(options.scriptUrl); + } } else { // If we already have the Piwik object we can resolve any pending // promises immediately.