Browse Source

Moved tracking to another file

Jeroen De Meerleer 5 months ago
parent
commit
0ccceba60b

+ 7 - 1
src/JeroenED/PortfolioBundle/Resources/public/js/analytics.js

@@ -7,4 +7,10 @@ _paq.push(['enableLinkTracking']);
   _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);
-})();
+})();
+
+function matomo_pageview() {
+	_paq.push(['setDocumentTitle', document.title]);
+	_paq.push(['setCustomUrl', document.location]);
+	_paq.push(['trackPageView']);
+}

+ 3 - 6
src/JeroenED/PortfolioBundle/Resources/public/js/jeroened.js

@@ -78,8 +78,7 @@ $(document).ready(function() {
 window.onhashchange = function() {
     updateTitle();
     if (!no_analytics) {
-        _paq.push(['setDocumentTitle', document_title]);
-        _paq.push(['trackPageView']);
+        matomo_pageview()
     }
 }
 window.onpopstate = function(e) {
@@ -174,8 +173,7 @@ function OpenPage(page, popState) {
             hastags = true;
             history.pushState(null, "", "/" + page + hash);
             if (!no_analytics) {
-                _paq.push(['setDocumentTitle', document_title]);
-                _paq.push(['trackPageView']);
+                matomo_pageview()
             }
         }
     });
@@ -189,8 +187,7 @@ function ClosePage(previousPage, popState) {
     if (popState) {
         history.pushState(null, "", previousPage + hash);
         if (!no_analytics) {
-            _paq.push(['setDocumentTitle', document_title]);
-            _paq.push(['trackPageView']);
+            matomo_pageview()
         }
     }
 }