Skip to main content

Configure a tracker with the Unity tracker

The Tracker object is responsible for co-ordinating the saving and sending of events as well as managing the optional Session object.

Constructor

Argument NameDescriptionRequired?Default
emitterThe Emitter object you createYesNull
trackerNamespaceThe name of the tracker instanceYesNull
appIdThe application IDYesNull
subjectThe Subject that defines a userNoNull
sessionThe Session object you createNoNull
platformThe device the Tracker is running onNoMobile
base64EncodedIf we base 64 encode json valuesNoTrue
userAnonymisationEnables client-side user anonymization. Omits user identifiers (userId, domainUserId, networkUserId) and any explicitly-set ipAddress from all events. Note: this does not affect the IP address captured by the collector from the network connection, use server anonymisation for that.NoFalse

A full Tracker construction should look like the following:

csharp
IEmitter e1 = new AsyncEmitter ("com.collector.acme")
Subject subject = new Subject();
Session session = new Session(null);
Tracker t1 = new Tracker(e1, "Namespace", "AppId", subject, session, DevicePlatforms.Desktop, true);

All of these variables can be altered after creation with the accompanying tracker.SetXXX() function.

Functions

The Tracker also contains several critical functions that must be used to start Tracking.

StartEventTracking()

This function must be called before any events will start being stored or sent. This is due to the fact that we do not want to start any background processing from the constructors so it is left up to the developer to choose when to start everything up.

This function:

  • Starts the background emitter thread
  • Starts the background event processor thread
  • Starts the background session check timer (Optional)

Once this is run everything should be in place for asynchronous event tracking.

StopEventTracking()

If you need to temporarily halt the Tracker from tracking events you can run this function. This will bring all event processing, sending and collection to a halt and nothing will be started again until StartEventTracking() is fired again.

Track(IEvent)

This is the function used for Tracking all events.

csharp
tracker.Track(IEvent newEvent);

SetUserAnonymisation(bool)

Enables or disables user anonymization. When enabled, the userId, domainUserId, networkUserId, and ipAddress fields are omitted from all events. This can also be set at construction time via the userAnonymisation parameter.

csharp
tracker.SetUserAnonymisation(true);

On this page

Want to see a custom demo?

Our technical experts are here to help.