Browse Source

Updated matomo code

Jeroen De Meerleer 5 months ago
parent
commit
90d49df791
1 changed files with 16 additions and 9 deletions
  1. 16 9
      src/JeroenED/PortfolioBundle/Resources/public/js/analytics.js

+ 16 - 9
src/JeroenED/PortfolioBundle/Resources/public/js/analytics.js

@@ -1,16 +1,23 @@
-var _paq = _paq || [];
+var _paq = window._paq || [];
+/* tracker methods like "setCustomDimension" should be called before "trackPageView" */
 _paq.push(['trackPageView']);
 _paq.push(['enableLinkTracking']);
 (function() {
-  var u="//matomo.jeroened.be/";
-  _paq.push(['setTrackerUrl', u+'piwik.php']);
-  _paq.push(['setSiteId', '1']);
-  var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
-  g.type='text/javascript'; g.async=true; g.defer=true; g.src=u+'piwik.js'; s.parentNode.insertBefore(g,s);
+    var u = "https://matomo.jeroened.be/";
+    _paq.push(['setTrackerUrl', u + 'matomo.php']);
+    _paq.push(['setSiteId', '1']);
+    var d = document,
+        g = d.createElement('script'),
+        s = d.getElementsByTagName('script')[0];
+    g.type = 'text/javascript';
+    g.async = true;
+    g.defer = true;
+    g.src = u + 'matomo.js';
+    s.parentNode.insertBefore(g, s);
 })();
 
 function matomo_pageview() {
-	_paq.push(['setDocumentTitle', document.title]);
-	_paq.push(['setCustomUrl', document.location]);
-	_paq.push(['trackPageView']);
+    _paq.push(['setDocumentTitle', document.title]);
+    _paq.push(['setCustomUrl', document.location]);
+    _paq.push(['trackPageView']);
 }