-
-
Save markknol/66f4eee7fdebfb50a685 to your computer and use it in GitHub Desktop.
This file contains 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
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