Assuming you have completed the Actionscript 3 Tracker Setup for your project, you are now ready to initialize the AS3 Tracker.
Importing the module
Import the AS3 Tracker's classes into your AS3 code like so:
That's it - you are now ready to initialize a Tracker instance.
Creating a Tracker
To instantiate a tracker in your code simply instantiate the
Tracker(emitter:Emitter, namespace:String, appId:String, subject:Subject, stage:Stage = null, base64Encoded:Boolean = true)
var t1:Tracker = new Tracker(emitter, "AF003", "cf", user1Subject, this.stage, true);
|The Emitter object you create
|The name of the Tracker instance
|The application ID
|The Subject that defines a user
|No (default null)
|The stage property of a DisplayObject
|No (Default null)
|Whether to enable base 64 encoding
|No (Default true)
The emitter to which the tracker will send events. See Emitters for more on emitter configuration.
The user which the Tracker will track. This should be an instance of the Subject class. You don't need to set this during Tracker construction; you can use the
Tracker.setSubject method afterwards. In fact, you don't need to create a subject at all. If you don't, though, your events won't contain user-specific data such as timezone and language.
If provided, the
namespace argument will be attached to every event fired by the new tracker. This allows you to later identify which tracker fired which event if you have multiple trackers running.
appId argument lets you set the application ID to any string.
By default, unstructured events and custom contexts are encoded into Base64 to ensure that no data is lost or corrupted. You can turn encoding on or off using the Boolean
Change the tracker's platform with
You can change the platform by calling:
For a full list of supported platforms, please see the Snowplow Tracker Protocol.