Add Google Analytics tracking.
authorAlexandre Segura <mex.zktk@gmail.com>
Thu, 13 Apr 2017 17:09:17 +0200
changeset 463 a4d4774eb146
parent 462 0572214c8546
child 464 655136b09cf3
Add Google Analytics tracking.
src/iconolab/templates/iconolab_base.html
src/iconolab/templates/partials/google_analytics.html
--- a/src/iconolab/templates/iconolab_base.html	Wed Apr 12 19:41:30 2017 +0200
+++ b/src/iconolab/templates/iconolab_base.html	Thu Apr 13 17:09:17 2017 +0200
@@ -41,5 +41,8 @@
       <!-- Webpack devServer script to handle page reload -->
       <script src="http://localhost:8001/webpack-dev-server.js" type="text/javascript"></script>
       {% endif %}
+      {% if not "localhost" in request.get_host %}
+      {% include "partials/google_analytics.html" %}
+      {% endif %}
 	</body>
 </html>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/iconolab/templates/partials/google_analytics.html	Thu Apr 13 17:09:17 2017 +0200
@@ -0,0 +1,9 @@
+<script>
+  (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
+  (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
+  m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
+  })(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
+
+  ga('create', 'UA-30064213-5', 'auto');
+  ga('send', 'pageview');
+</script>