Skip to main content
Now that you have created your Statsig account, and perhaps even your first feature, this guide will help you make your app a bit more flexible with Dynamic Config. Whether it be for server-side rendered UI, rate limiting configurations, ranking systems, algorithms, etc. Dynamic Config can help you update configurations on the fly.
This guide focuses on a client-side example, as it is easier to illustrate how Dynamic Configs work and can be used. You can and still should use Dynamic Config on the server side as well.
In this guide, we will be building a front page banner - something that may show up on an ecommerce site to advertise an upcoming sale, for instance. Here, I will apply it to a stripped down version of the Statsig homepage. It will look something like this green banner when we are finished:
UI for mac users
Codepen ExampleThis example is implemented in a codepen where you can see the actual code, or fork it to quickly test your own Dynamic Configs.

Step 1 - Create a new Dynamic Config

Start by creating a new Dynamic Config. Dynamic Configs live under the “Feature Management” tab in the Statsig Console.Pick a name related to the set of variables this config will hold. Since we are building a homepage banner, let’s call it “Banner Config”:
Create Dynamic Config
Great! We have created an (empty) Dynamic Config. It returns the default value (an empty JSON object) whenever it is evaluated. For our example, we are going to add some options to populate a homepage banner. The end goal is to show a targeted banner to a few different sets of developers: those likely to use a .NET SDK, and those more likely to use a Swift SDK. Let’s keep our targeting simple here: we want to promote the new .NET SDK to anyone that is browsing our site on the Windows operating system, and the new Swift SDK to anyone browsing on MacOS. That takes us to steps 2 and 3.

Step 2 - Create Targeting Rule(s) and Conditions

First, let’s add the Window’s rule. Select “Add Targeting”, and then “Add new Rule”:
Add Rule
Though Feature Gates and Dynamic Config share the same powerful user segmentation and targeting tools, they differ in what you return for those different sets of users. Feature Gates are intended to be super lightweight, and only return a boolean indicating the user matched one of the rules. Dynamic Configs, on the other hand, can return a different JSON blob of data for each rule!

Step 3 - Update the Return Value for Users Matching Each Rule

This is the rough schema we want to return:
And that’s it! With just a handful of javascript, we integrated with the Statsig SDK and started using the Dynamic Config we created. Now, without updating our website, we can add a new rule to the Dynamic Config and return a completely new banner to a different set of people! Here’s what it looks like for me, viewing this webpage in chrome on a Mac:
UI for mac users
We hope this inspires some ideas of what you could do with your app/website/backend service, and we can’t wait to see what you build.