1
0
mirror of https://github.com/kremalicious/gatsby-plugin-matomo.git synced 2024-12-22 09:13:19 +01:00

Scoping js variables to avoid polluting global scope

This commit is contained in:
Julien Blatecky 2018-07-29 09:35:46 +02:00
parent a96e8ea5f8
commit c4b21bf5ce
No known key found for this signature in database
GPG Key ID: 36FC0EA89369793D

View File

@ -16,8 +16,10 @@ function buildTrackingCode(pluginOptions) {
window._paq.push(['enableHeartBeatTimer']);
window.start = new Date();
var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
g.defer=true; g.async=true; g.src='${script}'; s.parentNode.insertBefore(g,s);
(function() {
var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
g.type='text/javascript'; g.async=true; g.defer=true; g.src='${script}'; s.parentNode.insertBefore(g,s);
})();
if (window.dev === true) {
console.log('[Matomo] Tracking initialized')