Skip to main content

Logging Events

After creating your first gate, you want to start logging events in order for the system to understand what you care about. These events are then automatically derived into metrics and used to quantify the impact of your features on the health of the overall product.

How to log events

There are a few ways Statsig can ingest events: via one of our Server/Client SDKs, connecting to a 3rd party like Segment, mParticle, or other Analytics provider listed in our Integrations, or via our metrics import http APIs.

Logging events via SDKs

All our SDKs provide a very simple API to log events. They look like this:

statsig.logEvent(
event_name,
optional_event_value,
optional_event_metadata
);

Where event name describes a notable event in your product, like sign_up, achievement_unlocked, add_to_cart, check_out, etc.

These events can optionally take an event value. For instance, you can use this field to specify the type of achievement that was unlocked, or the name of the product that was added to cart, or the price of the item that was purchased.

And finally, the metadata field allows you to specify even more details about the event. Here's an couple examples of how a logEvent call looks like:

statsig.logEvent(
'add_to_cart', // Name
19.99, // Price
{
item_id: 'BC22010',
cart_size: 2,
user_segment: 'first_time_purchaser',
}
);

An example in CSharp

StatsigClient.LogEvent(
"level_completed", // Event Name
11, // Level number
new Dictionary<string, string>()
{
{ "score", "452" }
}
);
Log as much as you want

We encourage you to log as many events as you can and want. The more events there are, the more holistic picture you will get when you are building and releasing new features.

Where do these events end up?

The events you log is aggregated and analyzed by Statsig to give you useful metrics. These can be viewed in the Metrics Tab.

Screen Shot 2022-06-17 at 11 46 12 AM

Statsig also provides a view into a set of derived user metrics like DAU, WAU, Stickiness, etc. just based on the events you log. Here's a view of those metrics available in the Charts page in Metrics Tab.

Screen Shot 2022-06-17 at 11 47 14 AM

Metrics for Experiments

Metrics will also make there way into your experiment results. When analyzing the impact of one of your experiments, you will need to send Statsig event data to join with the different groups that users were assigned to in an experiment. The experiment results section will then show the difference in metrics between groups, and whether that difference is considered "Statistically Significant" - or Statsig, as we like to say :)

Screen Shot 2022-06-17 at 11 48 34 AM