How to Track Events
To start tracking events in your project, first add the Strivr.SDK
namespace to your script(s)
using Strivr.SDK;
csharp
To track an event, call the TrackEvent
method:
StrivrAnalytics.TrackEvent("Example Event Name").End();
csharp
The argument for the TrackEvent
method is a string that represents the name of the event. Event names must be non-empty strings between 1-64 characters, and must contain only alphanumeric characters (a-zA-Z0-9), spaces, underscores, or dashes. When constructing your event names, it’s best to optimize for readability so the dashboard will be human-readable.
You can add any number of parameters to an event. To do so, simply chain the Add
method to the TrackEvent
call.
Add(string key, string value)
csharp
There are multiple overloads for this method that accept the value as a different type including float
, double
, int
, bool
, Vector3
, or TimeSpan
. For any other types, use the ToString()
method when possible. Key values follow the same rules as event names, must be non-empty strings between 1-64 characters, and must contain only alphanumeric characters (a-zA-Z0-9), spaces, underscores, or dashes. Again, optimize for readability.
Examples of usage:
StrivrAnalytics.TrackEvent("Sample Event").End();
csharp
StrivrAnalytics.TrackEvent("Clicked Object")
.Add("Object Name", hit.transform.name)
.Add("Click Position", hit.point)
.Add("Click Duration", holdTime)
.Add("Experience Name", experienceName)
.End();
csharp