From 5849893a7c9a4eb75b36c0b03cd7f39ebfc2c430 Mon Sep 17 00:00:00 2001 From: Christian Mueller Date: Sun, 10 Jun 2012 22:16:01 +0200 Subject: [PATCH] google analytics code added --- .gitignore | 1 - resources/public/js/google-analytics.js | 9 +++++++++ src/NoteHub/views/common.clj | 4 +++- 3 files changed, 12 insertions(+), 2 deletions(-) create mode 100644 resources/public/js/google-analytics.js diff --git a/.gitignore b/.gitignore index b5c1da3..52c0ff5 100644 --- a/.gitignore +++ b/.gitignore @@ -6,5 +6,4 @@ pom.xml /lib/ /classes/ .lein-* -resources/public/js/* .crossover-cljs diff --git a/resources/public/js/google-analytics.js b/resources/public/js/google-analytics.js new file mode 100644 index 0000000..b074c85 --- /dev/null +++ b/resources/public/js/google-analytics.js @@ -0,0 +1,9 @@ +var _gaq = _gaq || []; +_gaq.push(['_setAccount', 'UA-32546723-1']); +_gaq.push(['_trackPageview']); + +(function() { + var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true; + ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js'; + var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s); +})(); diff --git a/src/NoteHub/views/common.clj b/src/NoteHub/views/common.clj index 4ce0bdc..b92951d 100644 --- a/src/NoteHub/views/common.clj +++ b/src/NoteHub/views/common.clj @@ -3,6 +3,7 @@ [NoteHub.settings :only [get-message]] [NoteHub.views.css-generator] [noir.core :only [defpartial]] + [noir.options :only [dev-mode?]] [hiccup.page :only [include-js html5]] [hiccup.element :only [javascript-tag]])) @@ -22,7 +23,8 @@ "&subset=latin,cyrillic") " " "+") :rel "stylesheet" :type "text/css"}] - [:style {:type "text/css"} (global-css params)]] + [:style {:type "text/css"} (global-css params)] + (if-not dev-mode? (include-js "/js/google-analytics.js"))] (if (params :js) [:body content (javascript-tag "var CLOSURE_NO_DEPS = true;")