The HTML snippet wraps an instance of the Statsig JavaScript SDK. Providing your client API key in the URL auto-initializes the SDK, as shown in the installation step.
Move to manual initialization if you need any of the following:
custom user properties
custom initialization options
check gates, configs, experiments, or log events
To manually initialize an instance of the SDK, remove the key parameter from the script tag and do the following:
The StatsigClient instance you create is also available via window.Statsig, so you can reference it globally.
Your StatsigClient instance provides access to all methods in the JavaScript SDK. Go to that documentation for initialization details and core methods.
Can I customize the initialization logic?
Yes. Remove the client API key from the URL. The HTML snippet is the JavaScript SDK. Providing an API key in the URL auto-initializes an instance. To skip auto-initialization, omit the key and create your own instance. Go to the JavaScript SDK Getting Started Guide for details.
Creating an instance using the HTML snippet differs from installing through npm: