Last active
May 25, 2016 04:48
-
-
Save spaced/34544395414404b8036a to your computer and use it in GitHub Desktop.
Small Scalajs facade for google analytics events
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
object EventTracker { | |
def isScriptLoaded=js.Dynamic.global.ga.isInstanceOf[js.Function] | |
def sendEvent(category:String,action:String,label:String):Unit={ | |
if (isScriptLoaded) GoogleAnalytics.ga("send","event",category,action,label) | |
} | |
def sendEvent(category:String,action:String,label:String,value:String):Unit={ | |
if (isScriptLoaded) GoogleAnalytics.ga("send","event",category,action,label,value) | |
} | |
} | |
@js.native | |
object GoogleAnalytics extends js.GlobalScope { | |
def ga(send:String,event:String,category:String,action:String,label:String ): Unit = js.native | |
def ga(send:String,event:String,category:String,action:String,label:String,value:js.Any ): Unit = js.native | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment