diff --git a/app/bundles/CoreBundle/EventListener/BuildJsSubscriber.php b/app/bundles/CoreBundle/EventListener/BuildJsSubscriber.php index 605c89e854d..375b0923513 100644 --- a/app/bundles/CoreBundle/EventListener/BuildJsSubscriber.php +++ b/app/bundles/CoreBundle/EventListener/BuildJsSubscriber.php @@ -423,6 +423,12 @@ enumerable: false, return matches; } } + +MauticJS.ensureEventContext = function(event, context0, context1) { + return (typeof(event.detail) !== 'undefined' + && event.detail[0] === context0 + && event.detail[1] === context1); +}; JS; $event->appendJs($js, 'Mautic Core'); } diff --git a/app/bundles/PageBundle/EventListener/BuildJsSubscriber.php b/app/bundles/PageBundle/EventListener/BuildJsSubscriber.php index d03a6957043..3f5c793b40b 100644 --- a/app/bundles/PageBundle/EventListener/BuildJsSubscriber.php +++ b/app/bundles/PageBundle/EventListener/BuildJsSubscriber.php @@ -241,7 +241,9 @@ function() { // Process pageviews after new are added document.addEventListener('eventAddedToMauticQueue', function(e) { - m.sendPageview(e.detail); + if (MauticJS.ensureEventContext(e, 'send', 'pageview')) { + m.sendPageview(e.detail); + } }); })(MauticJS, location, navigator, document); JS;