Parcourir la source

Support for GA Tracking code

yjouanique il y a 7 ans
Parent
commit
224291edfa
2 fichiers modifiés avec 16 ajouts et 0 suppressions
  1. 6 0
      api/functions/organizr-functions.php
  2. 10 0
      index.php

+ 6 - 0
api/functions/organizr-functions.php

@@ -1115,6 +1115,12 @@ function getCustomizeAppearance()
 							'value' => 'bottom'
 						)
 					)
+				),
+				array(
+					'type' => 'input',
+					'name' => 'gaTrackingID',
+					'label' => 'Google Analytics Tracking ID (e.g. UA-XXXXXXXXX-X)',
+					'value' => $GLOBALS['gaTrackingID']
 				)
 			),
 			'Colors & Themes' => array(

+ 10 - 0
index.php

@@ -298,6 +298,16 @@
 <script src="https://js.pusher.com/4.1/pusher.min.js"
         integrity="sha384-e9MoFh6Cw/uluf+NZ6MJwfJ1Dm7UOvJf9oTBxxCYDyStJeeAF0q53ztnEbLLDSQP"
         crossorigin="anonymous"></script>
+<?php if ($GLOBALS['gaTrackingID']) { ?>
+    <script async src="https://www.googletagmanager.com/gtag/js?id=<?php echo $GLOBALS['gaTrackingID']; ?>"></script>
+    <script>
+    window.dataLayer = window.dataLayer || [];
+    function gtag(){dataLayer.push(arguments);}
+    gtag('js', new Date());
+
+    gtag('config', '<?php echo $GLOBALS['gaTrackingID']; ?>');
+    </script>
+<?php } ?>
 <?php echo pluginFiles('js');
 echo formKey(); ?>
 </body>