Documentation Index
Fetch the complete documentation index at: https://docs.statsig.com/llms.txt
Use this file to discover all available pages before exploring further.
Inbound Integration (Events flow from GTM dataLayer to Statsig)
This integration will allow customers using Statsig on the web to leverage their existing Google Tag manager configuration to track events to Statsig. This saves customers from having to retag their web properties with calls specific to Statsig’s SDK. This integration uses a global listener to consume all GTM triggers and dispatch a corresponding event back to Statsig.
Setup
Step 1: Broadcast Statsig client readiness to GTM
The tracking code within GTM will need to know when the Statsig client is ready to use for tracking. To do so, you’ll need to broadcast a window-level event and pass the statsig instance for the GTM tag code to use. In your initialize call, implement theinitCompletionCallback callback as follows:
Using @statsig/js-client
Using statsig-js
Step 2: Create new tag

Step 3: Choose tag type
Choose “Custom HTML” for tag type, and paste this GTM code (including script tag)
Step 4: Adjust fire options
Under Advanced Settings under “Tag Firing options”, select “Once per page”
Step 5: Set Tag Trigger
Below the “Tag Configuration” section, set the Trigger to “Initialization - All Pages” Option.
Step 6: Save tag and test
After saving the tag, and publishing your updated GTM tag, tracking will be done automatically without any additional configuration. To debug the integration, you can set a local storage entrydebug_ss_gtm with any value on your webpage. Now, you’ll console log statements for each tracking call being dispatched to Statsig. You can also inspect your browser’s network traffic to see events being tracked.
GTM Code
The code below assumes that the statsig client lives at
window.statsigOutbound Integration (GTM Data is enriched with Statsig test assignments)
This pattern will allow you to enrich your GTMdataLayer with experiment assignment information.

initialize call, you should bind an EventEmitter listener that captures the assigned experiment name and test group, and push it into the dataLayer as follows. Note that the argument passed to the callback contains rich context about the assignment. Please modify the GTM dataLayer properties to your liking.