Skip to main content

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.
Statsig log stream showing GTM events
(statsig log stream showing GTM events flowing in)

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 the initCompletionCallback callback as follows:

Using @statsig/js-client