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

Merge pull request #6 from Creatiwity/global-var-removal

Scoping js variables to avoid polluting global scope
This commit is contained in:
Matthias Kretschmann 2018-08-06 11:25:06 +02:00 committed by GitHub
commit 226115db02
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

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')