Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
move google analytics setup to clojurescript
  • Loading branch information
andrew committed Jun 13, 2016
1 parent a700224 commit 2bbf460
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 14 deletions.
3 changes: 2 additions & 1 deletion project.clj
Expand Up @@ -17,7 +17,8 @@
[bidi "2.0.9"] ; routing
[kibu/pushy "0.3.6"] ; auto html5 history

[cljsjs/moment "2.10.6-4"]] ; time
[cljsjs/moment "2.10.6-4"] ; time
[cljsjs/google-analytics "2015.04.13-0"]] ; analytics

:min-lein-version "2.5.3"

Expand Down
10 changes: 0 additions & 10 deletions resources/public/index.html
Expand Up @@ -9,15 +9,5 @@
<div id="app"></div>
<script src="js/compiled/app.js"></script>
<script>ulysses.core.init();</script>

<!-- Google Analytics -->
<script>
window.ga=window.ga||function(){(ga.q=ga.q||[]).push(arguments)};ga.l=+new Date;
ga('create', ulysses.config.google_analytics_code_real, 'auto');
ga('require', 'autotrack');
ga('send', 'pageview');
</script>
<script async src="https://www.google-analytics.com/analytics.js"></script>
<!-- End Google Analytics -->
</body>
</html>
2 changes: 0 additions & 2 deletions src/cljs/ulysses/config.cljs
Expand Up @@ -7,8 +7,6 @@
(env/def
google-analytics-code "UA-XXXXX-Y")

(def ^:export google-analytics-code-real google-analytics-code)

;; from closure defines ----

(def ^:export debug?
Expand Down
3 changes: 2 additions & 1 deletion src/cljs/ulysses/core.cljs
Expand Up @@ -6,7 +6,7 @@
[ulysses.routes :as routes]
[ulysses.views :as views]
[ulysses.config :as config]
[autotrack]))
[ulysses.lib.analytics :as analytics]))

(when config/debug?
(println "dev mode"))
Expand All @@ -31,6 +31,7 @@
time))))

(defn ^:export init []
(analytics/start)
(routes/app-routes)
(dispatch-sync [:initialize-db])
(mount-root)
Expand Down
9 changes: 9 additions & 0 deletions src/cljs/ulysses/lib/analytics.cljs
@@ -0,0 +1,9 @@
(ns ulysses.lib.analytics
(:require [cljsjs.google-analytics]
[ulysses.config :as config]
[autotrack]))

(defn start []
(js/ga "create" config/google-analytics-code "auto")
(js/ga "require" "autotrack")
(js/ga "send" "pageview"))

0 comments on commit 2bbf460

Please sign in to comment.