package temple.net.tracking.analytics; | |
/** | |
* @author Thijs Broerse | |
*/ | |
class GATracker | |
{ | |
public static var debug:Bool; | |
static public function trackPageview(pageURL:String):Void | |
{ | |
call(["_trackPageview", pageURL]); | |
} | |
static public function trackEvent(category:String, action:String, ?label:String, ?value:Float):Void | |
{ | |
var args:Array<Dynamic> = ["_trackEvent", category, action]; | |
if (label != null && label != "") | |
{ | |
args.push(label); | |
if (!Math.isNaN(value)) args.push(value); | |
} | |
call(args); | |
} | |
static private function call(args:Array<Dynamic>):Void | |
{ | |
#if flash | |
if (flash.external.ExternalInterface.available) | |
{ | |
flash.external.ExternalInterface.call("_gaq.push", args); | |
} | |
else | |
{ | |
if (debug) trace(args); | |
} | |
#elseif js | |
untyped _gaq.push(args); | |
#end | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment