Google Analytics tracking in ClojureScript
When you integrate advanced analytics in to your ClojureScript application, you will get into moment when you need to call ga
tracking function. You can define all arities, but it is unnecessary work. We can simply translate into JavaScript arguments application.
(defn ga [& more]
(when js/ga
(.. (aget js/window "ga")
(apply nil (clj->js more)))))
First we check, if global ga
function is present. To prevent rename of ga
function name in advanced mode compilation, we have to array access it (aget
) from global object. Then we apply arguments converted to JavaScript Array.
Written by Aleš Roubíček
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Clojurescript
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#