Skip to main content

Event Webhook

Incoming

The Statsig Event Webhook allows you to log event data to Statsig from third party apps or other external sources to provide additional insights to your Statsig experiments and metrics.

Before using the Webhook, you will need to obtain your Projects' server secret key. An example call to the Statsig Event Webhook should look like the following:

HTTP
POST https://api.statsig.com/v1/webhooks/event_webhook
Headers
Content-Type: application/json
Accept: */*
STATSIG-API-KEY: {STATSIG_SERVER_SECRET}
JSON Body
{
"user": {
"userID": {USER_ID},
...
},
"event": {EVENT_NAME},
"value": {VALUE},
"metadata": {
"example_field_1": {EXAMPLE_VALUE_1},
"example_field_2": {EXAMPLE_VALUE_2},
...
},
timestamp: {TIMESTAMP}
}

Outgoing

If you are using a service that we don't have an official integration for, you can always use our Generic Webhook integration.

This integration just sends raw events to the provided webhook url.

Setup

In your Project Settings, under the Integrations tab. Enable the Generic Webhook integration.

In the dialog that appears, enter the url of you destination webhook and then hit Enable to save the url and enable this integration.

integration-dialog

You can then set which events you want forwarded to your webhook using the Event Filtering dialog.

Event Format

Events will be sent to your webhook in batches in a JSON format. The structure of a Statsig Event sent to your webhook will look like the following:

FieldTypeDescription
eventNameStringName of the event provided
userJSONStatsig User Object
userIDStringUser ID provided
timestampNumberTimestamp in MS of the event
valueStringValue of the event provided
metadataJSONCustom Metadata provided
statsigMetadataJSONMetadata added by Statsig
timeUUIDStringUUID for the event

Feature Gate Exposure Format

For events representing an exposure for a Statsig Feature Gate, the event will be in the following format:

{
eventName: "statsig::gate_exposure",
statsigMetadata: {
gate: <Name of the gate that was exposed>,
gateValue: <True/False depending on if user passed the gate>,
gateGroupName: <Name of the Rule the user was checked against>,
ruleID: <Unique identifier for the Rule>
}
}

Experiment Exposure Format

For events representing an exposure for a Statsig Experiment, the event will be in the following format:

{
eventName: "statsig::experiment_exposure",
statsigMetadata: {
config: <Name of the gate that was exposed>,
experimentGroupName: <Name of the Group in the experiment the user was allocated to>,
ruleID: <Unique identifier for the Group>
}
}

Example Batch

[
{
eventName: "page_view"
user: {userID: "user_1", country: "US"},
userID: "user_1",
timestamp: 1644520566967,
value: "example_value",
metadata: {page: "home_page"},
statsigMetadata: {},
timeUUID: "f4c414a0-8aa5-11ec-a8a3-0242ac120002"
},
{
eventName: "statsig::gate_exposure"
user: {userID: "user_1", country: "US"},
userID: "user_1",
timestamp: 1644520566968,
value: "",
metadata: {},
statsigMetadata: {gate: "test_gate", gateValue: true, gateGroupName: "US Users", ruleID: "5T2Gg0bwizTh9heDKL1El7"},
timeUUID: "f4c414a0-8aa5-11ec-a8a3-0242ac120003"
},
{
eventName: "statsig::experiment_exposure"
user: {userID: "user_1", country: "US"},
userID: "user_1",
timestamp: 1644520566969,
value: "",
metadata: {},
statsigMetadata: {config: "test_experiment", experimentGroupName: "Control", ruleID: "5T2Gg0bwizTh9heUKL1El7"},
timeUUID: "f4c414a0-8aa5-11ec-a8a3-0242ac120004"
}
]

Filtering Events

Once you've enabled outbound events to your webhook, you can select which categories of Statsig events you want to export by clicking on the Event Filtering button and checking the appropriate boxes as shown below.

event-filter-button

event-filter-dialog

Still Stuck?

Join our Slack community and chat with our Engineers and Data Scientists