Measuring Experiments
Learn how to measure experiment results using autocapture, the manual tracking API, and Sidecar callbacks for analytics integrations.
Using Autocapture
Sidecar automatically tracks various web activities, letting you create simple and complex metrics in the Statsig console without writing code. Create a new metric in the Metrics tab on the Statsig console to get started. For a full list of automatically logged metrics, refer to Autocapture on the Web.Using the tracking API
You can track events manually for actions not captured by Autocapture. To track events to Statsig, callStatsigSidecar.logEvent, which accepts the same arguments as the Statsig JS SDK as documented in Logging an event. You can call this method before the init routine completes.// example order event
StatsigSidecar.logEvent('Order', null, {
total: 54.66,
units: 3,
unitAvgCost: 18.22
});
Per-assignment callback for outbound integrations
You can bind a callback that is invoked each time Sidecar activates an experiment assignment, including experiments activated later by prerun scripts.
This method must be defined before the Sidecar client script.
window.statsigSidecarConfig = {
onExperimentEvaluation: function (event) {
/**
* add your own callback routine here
* ie; annotating 3rd party analytics tools with assignment info
*/
window.dataLayer = window.dataLayer || [];
window.dataLayer.push({
event: "statsig_experiment_evaluation",
experiment_name: event.experimentName,
experiment_group_name: event.groupName,
});
}
}
The callback payload includes:
event.name- always"experiment_evaluation"event.experiment- the full Statsig experiment objectevent.experimentName- the Sidecar experiment name, or the Statsig experiment name as a fallbackevent.groupName- the assigned group / variant, ornullif unavailable
Post-experiment callback for one-time readiness hooks
You can bind window.postExperimentCallback to receive a callback after Sidecar finishes its initial run. This callback fires even when there are no experiments, but doesn't cover experiments activated later by prerun scripts.
window.postExperimentCallback = function(statsigClient, experimentIds) {
// One-time initialization hook after Sidecar finishes the initial run
}
Disabling all logging
To disable all logging to Statsig (both autocapture events and experiment exposure logging), append the following query string parameter to the Sidecar script URL: &autostart=0. This is useful for GDPR compliance. You can re-enable events later with client.updateRuntimeOptions({disableLogging: false}).
Was this helpful?