Log Custom Events
Logs one or more custom events for analytics and metric calculation. Events are used to measure experiment outcomes and user behavior.
Logs one or more custom events for analytics and metric calculation. Events are used to measure experiment outcomes and user behavior.
https://api.statsig.com/v1/log_eventAuthorizations
statsig-api-keystringrequiredapiKey (header)
Body
application/jsoneventsobject[]requiredArray of events to log
Show child attributes
eventNamestringrequiredName of the event
min length: 1valueoneOfOptional event value (string or number)
stringnumbertimeoneOfEvent timestamp (unix timestamp in milliseconds or ISO date string)
integer (format: int64)string (format: date-time)userobjectUser object for this specific event (overrides request-level user)
userIDstringPrimary user identifier
user-123emailstringUser email address
user@example.comformat: emailipstringUser IP address for geo-targeting
192.168.1.1userAgentstringUser agent string for device/browser targeting
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36countrystring2-letter country code (ISO 3166-1 alpha-2)
USlocalestringLocale/language code
en_USappVersionstringApplication version
1.2.3customobjectCustom user attributes for targeting (string, number, boolean, or array of strings)
{"subscription_plan":"premium","account_age_days":45,"is_beta_tester":true}privateAttributesobjectPrivate attributes used for evaluation but not logged to analytics
{"internal_user_id":"12345"}customIDsobjectAdditional custom identifier mappings
{"companyID":"company-456","deviceID":"device-789"}statsigEnvironmentobjectEnvironment tier for targeting
tierstringEnvironment tier
productionstagingdevelopmentmetadataobjectAdditional event metadata as key-value pairs
secondaryExposuresobject[]Secondary exposures for this event
gatestringrequiredName of the gate
gateValuestringrequiredGate value as string ('true' or 'false')
ruleIDstringrequiredRule ID that was evaluated
statsigMetadataobjectSDK metadata for tracking SDK type, version, and other diagnostic information
{"sdkType":"js-client","sdkVersion":"4.20.0","exposureLoggingDisabled":false}sdkTypestringSDK type sending the request (e.g., js-client)
sdkVersionstringSDK version
exposureLoggingDisabledbooleanWhen true, prevents the HTTP API from automatically logging exposures. Use this only if you will handle exposure logging yourself.
userobjectShared user object for all events (can be overridden per event)
Show child attributes
userIDstringPrimary user identifier
user-123emailstringUser email address
user@example.comformat: emailipstringUser IP address for geo-targeting
192.168.1.1userAgentstringUser agent string for device/browser targeting
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36countrystring2-letter country code (ISO 3166-1 alpha-2)
USlocalestringLocale/language code
en_USappVersionstringApplication version
1.2.3customobjectCustom user attributes for targeting (string, number, boolean, or array of strings)
{"subscription_plan":"premium","account_age_days":45,"is_beta_tester":true}privateAttributesobjectPrivate attributes used for evaluation but not logged to analytics
{"internal_user_id":"12345"}customIDsobjectAdditional custom identifier mappings
{"companyID":"company-456","deviceID":"device-789"}statsigEnvironmentobjectEnvironment tier for targeting
tierstringEnvironment tier
productionstagingdevelopmentstatsigMetadataobjectSDK metadata for tracking SDK type, version, and other diagnostic information
{"sdkType":"js-client","sdkVersion":"4.20.0","exposureLoggingDisabled":false}Show child attributes
sdkTypestringSDK type sending the request (e.g., js-client)
sdkVersionstringSDK version
exposureLoggingDisabledbooleanWhen true, prevents the HTTP API from automatically logging exposures. Use this only if you will handle exposure logging yourself.
Response
application/jsonsuccessbooleanrequiredWhether the request was successful
successbooleanrequiredWhether the request was successful
Was this helpful?