added matomo tracking code to site-plugin release_08112020-1118
authordanix <danix@danix.xyz>
Sun, 8 Nov 2020 10:18:46 +0000 (11:18 +0100)
committerdanix <danix@danix.xyz>
Sun, 8 Nov 2020 10:18:46 +0000 (11:18 +0100)
danixland-site-plugin.php

index 395263efcbe0b5a649a893da911b6d569dda9018..a6859e50c088670171fbbd33a445086aa26c3a0d 100644 (file)
@@ -76,3 +76,29 @@ add_action( 'wp_enqueue_scripts', 'baguette_enqueue_assets' );
  * Do not translate smileys into emoticons.
  */
 add_filter( 'option_use_smilies', '__return_false' );
+
+/*
+ # Add matomo tracking js code to head
+ */
+if ( ! function_exists( 'matomo_tracking' ) ) :
+       function matomo_tracking() {
+               ?>
+<!-- Matomo -->
+<script type="text/javascript">
+       var _paq = window._paq = window._paq || [];
+       /* tracker methods like "setCustomDimension" should be called before "trackPageView" */
+       _paq.push(['trackPageView']);
+       _paq.push(['enableLinkTracking']);
+       (function() {
+               var u="//lucky.danix.xyz/";
+               _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.src=u+'matomo.js'; s.parentNode.insertBefore(g,s);
+       })();
+</script>
+<!-- End Matomo Code -->
+       <?php
+       }
+endif;
+add_action( 'wp_head', 'matomo_tracking' );