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

save some lines

This commit is contained in:
Matthias Kretschmann 2018-05-23 01:05:36 +02:00
parent f9050ceaa2
commit 5034a3b8e5
Signed by: m
GPG Key ID: 606EEEF3C479A91F

View File

@ -5,7 +5,6 @@ function buildTrackingCode(pluginOptions) {
const html = `
window.dev = ${pluginOptions.dev}
if (window.dev === true || !(navigator.doNotTrack == '1' || window.doNotTrack == '1')) {
window._paq = window._paq || [];
window._paq.push(['setTrackerUrl', '${pluginOptions.matomoUrl}/piwik.php']);
@ -14,23 +13,18 @@ function buildTrackingCode(pluginOptions) {
window._paq.push(['trackPageView']);
window._paq.push(['enableHeartBeatTimer']);
window.start = new Date();
if (window.dev === true) {
console.log('[Matomo] Tracking initialized')
console.log('[Matomo] matomoUrl: ${pluginOptions.matomoUrl}, siteId: ${pluginOptions.siteId}')
}
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);
g.defer=true; g.async=true; g.src='${script}'; s.parentNode.insertBefore(g,s);
}
`
return (
<script
key={'gatsby-plugin-matomo'}
type="text/javascript"
dangerouslySetInnerHTML={{ __html: html }}
/>
)