From fd6683f3b234760fbe9446c0872612f770a877e6 Mon Sep 17 00:00:00 2001 From: Thibaut Courouble Date: Sat, 4 Jun 2016 10:14:28 -0400 Subject: [PATCH] Move tracking scripts inside the JS bundle --- assets/javascripts/application.js.coffee | 2 ++ assets/javascripts/tracking.js | 20 ++++++++++++++++++++ views/app.erb | 14 -------------- 3 files changed, 22 insertions(+), 14 deletions(-) create mode 100644 assets/javascripts/tracking.js diff --git a/assets/javascripts/application.js.coffee b/assets/javascripts/application.js.coffee index ae85f852..6bf87f1c 100644 --- a/assets/javascripts/application.js.coffee +++ b/assets/javascripts/application.js.coffee @@ -18,6 +18,8 @@ #= require_tree ./templates +#= require tracking + init = -> document.removeEventListener 'DOMContentLoaded', init, false diff --git a/assets/javascripts/tracking.js b/assets/javascripts/tracking.js new file mode 100644 index 00000000..6f505c5d --- /dev/null +++ b/assets/javascripts/tracking.js @@ -0,0 +1,20 @@ +try { + if (app.config.env == 'production') { + (function() { + (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-5544833-12', 'devdocs.io'); + ga('send', 'pageview'); + })(); + + (function() { + var _gauges=_gauges||[];!function(){var a=document.createElement("script"); + a.type="text/javascript",a.async=!0,a.id="gauges-tracker", + a.setAttribute("data-site-id","51c15f82613f5d7819000067"), + a.src="https://secure.gaug.es/track.js";var b=document.getElementsByTagName("script")[0]; + b.parentNode.insertBefore(a,b)}(); + })(); + } +} catch(e) { } diff --git a/views/app.erb b/views/app.erb index c034d735..c0ed5056 100644 --- a/views/app.erb +++ b/views/app.erb @@ -30,20 +30,6 @@
-<% if App.production? %><% end %>