Tech Spotlight: Implementing your first feature flag
copy gray iconlinkedin graytwitter grey

Tech Spotlight: Implementing your first feature flag

November 16, 2022

One of the most popular models for releasing software is the introduction of small iterative changes while safely building towards a more complete product. One of the benefits of this approach is ensuring a tight feedback loop while releasing new features. If the feature isn’t performing as expected, you can quickly course-correct to prevent making costly investments on a feature that won’t provide a meaningful return. A common tool that you may use to help control new feature releases and to monitor the success of that feature is called a feature flag.

With a quick Google search, you’ll find many service options that can help you implement feature flags (GrowthBook, Optimizely, etc). These services can give developers a means to get actionable data into the hands of a product team. That data is used to safely roll out new features, refine ideas quickly, and have confidence in knowing when you’ve done something that works well.

At Pinwheel, we use an experimentation framework called Statsig, which will be used for the examples below. If you’d like to follow along, your first five million Statsig events are free which provides plenty of room to explore the core features and make a determination about whether it makes sense for your team. By the end of this article, you’ll understand a few core concepts of an experiment framework and how to set up your first feature gate.

We ❤️ Python at Pinwheel, so the code snippets below will leverage the Python SDK that Statsig offers, but they currently support client and server SDKs for thirteen languages.

The power of an experiment framework comes from its flexibility. The concept of an “experiment” is very loose, so we’re constantly innovating new ways to derive value from  Statsig across all of our engineering teams. Common examples include:

  • A/B test a UX change to one of our public facing products
  • Gate access to a feature for a subset of customers
  • Controlled rollout for a change to one of our internal services

Before we write any code, we need to cover a couple of important fundamentals and handle some basic configuration inside Statsig’s Feature Gates menu.

Statsig’s product offering for implementing feature flags is called a Feature Gate.

Feature Gates

Feature Gates are one of Statsig’s most fundamental tools that can be used to control which users get exposed to a specific feature, product, service, etc. Feature Gates simply return a boolean value. In the typical feature gate example, you send contextual information at a point in your product flow and the experimentation framework will run that information against rules that you configure to determine which boolean value should be returned back to you.

To setup your first feature gate, go to the “Feature Gates” menu which should be located in the left side panel from your account dashboard and click “+ Create” to see this form:

    • Name is what you want the feature gate to be called. It’s a good idea to find a common naming convention for your team.
    • Tags give you a way to group a collection of feature gates together for easier filtering. We will leave it blank for now.
    • ID Type is the type of ID you’d like Statsig to use as a way of identifying a unique user in your product flow. We’ll use the default User ID type for now.

    After clicking “Create”, you’ll find yourself on the fg-demo-gate feature gate’s dashboard. From here, you can edit settings, view diagnostics/results, and configure rules for the feature gate.

    Rules

    Rules are the basic building blocks for a feature gate. Rules are essentially boolean expression chains that give you granular control over the traffic you’d like to have pass or fail your feature gate.

    You’ll notice an “All Rules” section that currently only has a default “ELSE” rule which is set to “always return false”. In other words, without any rules configured, all checks of this feature gate will fail. To fix that, click the “Add New Rule” button above the default rule. You’ll see a menu that looks something like this:

    • Criteria is the targeting criteria you’d like to use for this rule. We’ll leave it set to the default value of User ID.
    • Operator gives you options for matching the Criteria like Any of, None of, and Is null. We’ll use Any of to allow us to match this rule against any user-uuid that is sent through this gate.
    • Name is the name of the rule for identification against other rules.
    • Pass Percentage is exactly what it sounds like. We’ll set it to 100% pass for this demo.

    After you click “Add Rule”, you’ll see it appear in the list of rules you have configured for this feature gate. Once you’ve initialized the Statsig client in your application, it will poll for rule updates every ten seconds by default, so you can expect any changes to take effect almost immediately. Rules will be evaluated from top-to-bottom and are mutually exclusive, so you’ll want to make sure to keep ordering in mind as you organize them. With our feature gate and first rule configured, we are ready to write some code!

    Setting up the Statsig SDK

    You can get up and running quickly by installing the SDK with the package manager of your preferred language and writing a few lines of boilerplate code. From your terminal:

    After the package has been installed, you can initialize the SDK from inside your text editor:

    The sdk-api-key is something you’ll find in your “Project Settings” under “API Keys”. At this point, the Statsig client will fetch updates from Statsig in the background. You’re ready to use this client to check your new feature gate, but we have one more important Statsig concept to cover first!

    StatsigUser

    When working with an experiment framework like Statsig, it’s important to have consistent results for a user across all of your products and services. In other words, you’d like a user to always either pass or fail a feature gate each time it’s checked. This makes the out-of-the-box analytics even more powerful because it can now tie that user to multiple points throughout your product flow, giving you a richer visualization of their experience and ensuring that you’re presenting the user with congruent options.

    To manage tracking users, Statsig has the concept of a StatsigUser. The StatsigUser schema looks like this for the Python SDK:

    As you can see, there is flexibility in how you determine what makes a user unique for your feature gates, but you’ll typically only provide one or two values. With that out of the way, let’s finally test the feature gate!

    Testing the Feature Gate

    To check a StatsigUser against the fg-demo-gate feature gate, you may do something like this inside your application code:

    And for every follow-up gate check for the StatsigUser with an id of 1, as long as the target criteria matches one of the defined rules in this feature gate, you’ll get consistent results from the Statsig SDK. Following the gate check, you may choose to execute some code differently based on the result:

    And that’s all there is to it! You’ve now successfully setup and run a check against your first feature flag! We’ve only touched on the most basic concepts of an experiment framework like Statsig with a feature gate example, but most of these services offer even more powerful tools to conduct and monitor experiments across your organization. Some examples from Statsig include Events, Segments, Dynamic Configs, and Experiments.

    In the time that we have been using an experiment framework at Pinwheel, we’ve found it to be an invaluable asset in helping us in our mission to become the leader in payroll data connectivity.  If your team is looking for ways to expand your capabilities to run robust product experiments, maybe give one a try!

    Check out our related content down below to see other tech spotlights!

    Always stay up to date

    Thank you! Your submission has been received!
    Oops! Something went wrong while submitting the form.
    View our Privacy Policy   ➔

    Up next

    Citizens & Pinwheel Talk Primacy

    Citizens & Pinwheel Talk Primacy

    A conversation with Chris Powell, EVP & Head of Deposits, Citizens Bank and Kurtis Lin, Co-Founder & CEO, Pinwheel. Last month, Pinwheel hosted a webinar with the Consumer Bankers Association to explore our latest research on The Power of Primacy conducted in partnership with The Digital Banking Report. In a discussion moderated by Pinwheel CMO, Crystal Gopman, Chris Powell, EVP and Head of Deposits at Citizens Bank and Pinwheel CEO, Kurtis Lin, delved deep into the challenges banks are facing today as they compete for share of wealth with the modern consumer. 

    Read more  ➔
    Be the Amazon of banks  

    Be the Amazon of banks  

    The next time you’re browsing on your phone, add this idea to your cart: Does your bank need to engage customers less like an overworked teller and more like Amazon?In a climate of exploding technology and regulatory scrutiny, the BAI Banking Outlook: 2024 Trends survey identified the customer digital experience as a top priority for this year, citing technology integration and intuitive platforms as the pathways to engagement that’s personal, frictionless – and even somewhat fun. But as you know, fraud mitigation and other protocols can introduce drag and result in user drop-off. “Somewhat unfairly, customers measure their bank’s digital delivery of services against the practices of world-class online retailers,” the survey concludes. 

    Read more  ➔
    Enhancing digital trust: Inside Pinwheel's commitment to security

    Enhancing digital trust: Inside Pinwheel's commitment to security

    Ensuring Digital Security in the rapidly evolving digital world, the importance of security cannot be overstated. As the Chief Information Security Officer at Pinwheel, I'm at the forefront of our battle against digital threats. Our mission is clear: to safeguard our clients' data with the most robust security measures available. This dedication is embodied in our two flagship products: Pinwheel Core and Pinwheel Prime.

    Read more  ➔
    Who’s making money moves in 2024?

    Who’s making money moves in 2024?

    Are your new customer acquisition goals higher than ever in 2024? Yes? Then, you’re on trend. Late last year, the BAI surveyed 102 financial services organizations to gain insights for the coming year. The findings of the study, the BAI 2024 Banking Outlook, placed customer acquisition in the top two priorities—just behind deposit growth—for bankers. Coming in third? You can probably guess. Enhanced digital banking experiences. And we’re here for it. 

    Read more  ➔
    New study confirms direct deposit unlocks primacy

    New study confirms direct deposit unlocks primacy

    The report highlights a significant disconnect between banks' customer acquisition strategies and consumer behavior. While banks continue to invest heavily in account opening incentives, such as cash bonuses and promotional offers, these efforts often fall short of their intended goal. To the dismay of banks, although they spend high acquisition costs to attract new customers, many of these accounts remain dormant.

    Read more  ➔
    Consumer bank switching behavior demystified

    Consumer bank switching behavior demystified

    My january piece on the offer wars got me thinking: what actually motivates consumers to switch banks? Are rich account opening incentives turning heads, or is our industry missing the mark? To answer this question, we partnered with Savanta research to understand the inner dialogue of a consumer contemplating a new banking relationship.

    Read more  ➔
    The metrics you care about the most are now available in real-time

    The metrics you care about the most are now available in real-time

    Pinwheel was founded to unlock powerful income data for financial institutions, so that they can better serve their users with more personalized products, driving long term relationships that are proven to deliver better financial outcomes. Introducing the Dashboard Activity Page for Real-Time Engagement Insights.

    Read more  ➔
    New Jack Henry partnership makes it easier for community banks to take advantage of Pinwheel

    New Jack Henry partnership makes it easier for community banks to take advantage of Pinwheel

    We are thrilled to announce Pinwheel's new strategic partnership with Jack Henry, a leading financial technology company, which gives their customers a fast path to implementation for the industry's top performing Direct Deposit Switching solution. This collaboration is set to revolutionize the digital direct deposit setup experience for accountholders at community and regional financial institutions.

    Read more  ➔
     Pinwheel's CMO discusses bank competition for primacy in 2024

    Pinwheel's CMO discusses bank competition for primacy in 2024

    Banks rival top brands like Coke and P&G as the highest spending advertisers in the world. And bank marketing teams - channeling their best Cardi B energy - literally make money move with hundreds of millions of dollars at their disposal to hit annual growth goals. While the accounts keep rolling in, there’s a frantic scramble as institutions fumble in their attempts to convert active customers and meaningful engagement through aggressive, unsustainable offers. 

    Read more  ➔
    Hear from Pinwheel’s Chief revenue officer on growing profitably in 2024

    Hear from Pinwheel’s Chief revenue officer on growing profitably in 2024

    As the Chief Revenue Officer at Pinwheel, I speak to executives from the world’s top banks every day and I see first hand how rapidly the financial services industry is changing. With approximately 94% of the U.S. population holding bank accounts and a staggering 13 million new accounts opened in 2022, the competitive quest for primacy, or being the primary account for a customer, is more intense than ever. That’s why digital advertising spend is on track to close out 2023 by surpassing $30 billion.

    Read more  ➔
    Introducing the next generation of Automated Direct Deposit Switching

    Introducing the next generation of Automated Direct Deposit Switching

    Introducing our first-of-its-kind, reimagined automated direct deposit switching experience, expected to at least double end-to-end conversion.

    Read more  ➔
    Know Your Fraudster Q&A with Robert Reynolds

    Know Your Fraudster Q&A with Robert Reynolds

    Read more  ➔
    Fraud Fighers Chapter 1: Know Your Fraudster

    Fraud Fighers Chapter 1: Know Your Fraudster

    Read more  ➔
    This is how banks close the loop with branch guests: Introducing Pinwheel Smart Branch

    This is how banks close the loop with branch guests: Introducing Pinwheel Smart Branch

    Read more  ➔
    Introducing Pinwheel Deposit Switch 2.0, a revolutionary upgrade that maximizes coverage and conversion for every US worker

    Introducing Pinwheel Deposit Switch 2.0, a revolutionary upgrade that maximizes coverage and conversion for every US worker

    Deposit Switch 2.0 allows every US worker to update their direct deposit settings regardless of where their direct deposit comes from.

    Read more  ➔
    Key factors to consider before implementing a payroll connectivity API

    Key factors to consider before implementing a payroll connectivity API

    Before integrating a payroll connectivity API, you should evaluate it based on coverage, conversion, implementation, security, and compliance.

    Read more  ➔
    Enhance credit line management with income data

    Enhance credit line management with income data

    Read more  ➔
    See your customers’ earnings weeks into the future with projected earnings

    See your customers’ earnings weeks into the future with projected earnings

    Read more  ➔
    How to reduce default risk with consumer-permissioned data

    How to reduce default risk with consumer-permissioned data

    Read more  ➔
    Digital lending technologies and trends that are shaping the industry

    Digital lending technologies and trends that are shaping the industry

    Read more  ➔
    4 technologies that improve fraud detection in banking

    4 technologies that improve fraud detection in banking

    Read more  ➔
    Why automated income verification is a must-have feature for lenders

    Why automated income verification is a must-have feature for lenders

    Read more  ➔
    December product release: 10% increase in conversion, enhanced security and access to pay frequency data

    December product release: 10% increase in conversion, enhanced security and access to pay frequency data

    Read more  ➔
    A conversation with our Chief Information Security Officer

    A conversation with our Chief Information Security Officer

    Read more  ➔
    Former CFPB Deputy Director Raj Date Joins Pinwheel as an Advisor

    Former CFPB Deputy Director Raj Date Joins Pinwheel as an Advisor

    Read more  ➔
    Cash flow underwriting: Benefits & how to access cash flow data

    Cash flow underwriting: Benefits & how to access cash flow data

    Read more  ➔
    Why banks need a payroll connectivity API that prioritizes information security

    Why banks need a payroll connectivity API that prioritizes information security

    Read more  ➔
    How alternative credit data can benefit lenders

    How alternative credit data can benefit lenders

    Read more  ➔
    Tech Spotlight: Implementing your first feature flag

    Tech Spotlight: Implementing your first feature flag

    Read more  ➔
    Pinwheel Welcomes New Advisor, Ethan Yeh, to Advance Pinwheel’s Data Science Strategy

    Pinwheel Welcomes New Advisor, Ethan Yeh, to Advance Pinwheel’s Data Science Strategy

    Read more  ➔
    Tech spotlight: Securing access control across internal services

    Tech spotlight: Securing access control across internal services

    Read more  ➔
    The anatomy and potential of payroll data: Transforming complex data into insights

    The anatomy and potential of payroll data: Transforming complex data into insights

    Read more  ➔
    Beyond the credit score: Propelling consumer finance into the future with income data

    Beyond the credit score: Propelling consumer finance into the future with income data

    Read more  ➔
    Ayokunle (Ayo) Omojola joins Pinwheel’s Board of Directors

    Ayokunle (Ayo) Omojola joins Pinwheel’s Board of Directors

    Read more  ➔
    Conquering conversion: Engineering practices developed to help customers

    Conquering conversion: Engineering practices developed to help customers

    Read more  ➔
    Driving Customer Delight: From implementation and beyond

    Driving Customer Delight: From implementation and beyond

    Read more  ➔
    Pinwheel Supports Open Finance Data Security Standard

    Pinwheel Supports Open Finance Data Security Standard

    Read more  ➔
    How we design Pinwheel to solve real customer problems

    How we design Pinwheel to solve real customer problems

    Read more  ➔
    What is consumer-permissioned data and what are its benefits?

    What is consumer-permissioned data and what are its benefits?

    Read more  ➔
    How payroll data connectivity can help financial service providers in tumultuous market conditions

    How payroll data connectivity can help financial service providers in tumultuous market conditions

    Read more  ➔
    Pinwheel now supports document uploads to supplement payroll data

    Pinwheel now supports document uploads to supplement payroll data

    Read more  ➔
    Brian Karimi-Pashaki joins Pinwheel as Partnerships Lead

    Brian Karimi-Pashaki joins Pinwheel as Partnerships Lead

    Read more  ➔
    Optimizing for conversion with smarter employer mappings

    Optimizing for conversion with smarter employer mappings

    Read more  ➔
    What are super apps and how will they impact financial services?

    What are super apps and how will they impact financial services?

    Read more  ➔
    Increase conversions and maximize share of wallet with Pinwheel's new UX update

    Increase conversions and maximize share of wallet with Pinwheel's new UX update

    Read more  ➔
    Pinwheel announces support for taxes

    Pinwheel announces support for taxes

    Read more  ➔
    Ryan Nier Joins Pinwheel as the Company’s first General Counsel

    Ryan Nier Joins Pinwheel as the Company’s first General Counsel

    Read more  ➔
    The future of enabling earned wage access

    The future of enabling earned wage access

    Read more  ➔
    Deliver earned wage access faster with Pinwheel Earnings Stream

    Deliver earned wage access faster with Pinwheel Earnings Stream

    Pinwheel Earnings Stream provides the necessary data and intelligence to reliably offer earned wage access (EWA) at scale.

    Read more  ➔
    Digital transformation in banking in 2022: What it means, trends & examples

    Digital transformation in banking in 2022: What it means, trends & examples

    Read more  ➔
    June product release: Expanded connectivity to employers, a custom experience with Link API and more

    June product release: Expanded connectivity to employers, a custom experience with Link API and more

    Read more  ➔
    Pinwheelie Spotlight: LaRena Iocco, Software Engineer

    Pinwheelie Spotlight: LaRena Iocco, Software Engineer

    Read more  ➔
    Build fully custom experiences with Pinwheel’s Link API

    Build fully custom experiences with Pinwheel’s Link API

    Read more  ➔
    Pinwheel expands connectivity to 1.5M employers

    Pinwheel expands connectivity to 1.5M employers

    Read more  ➔
    Robert Reynolds joins Pinwheel as Head of Product

    Robert Reynolds joins Pinwheel as Head of Product

    Read more  ➔
    Pinwheel obtains highest security certification in the industry

    Pinwheel obtains highest security certification in the industry

    Read more  ➔
    Lauren Crossett becomes Pinwheel’s first Chief Revenue Officer

    Lauren Crossett becomes Pinwheel’s first Chief Revenue Officer

    Read more  ➔
    Everything you should know about the role of APIs in banking

    Everything you should know about the role of APIs in banking

    Read more  ➔
    Open finance: What is it and how does it impact financial services?

    Open finance: What is it and how does it impact financial services?

    Read more  ➔
    How automated direct deposit switching benefits traditional banks

    How automated direct deposit switching benefits traditional banks

    Read more  ➔
    Pinwheel Secure: Authentication optimized for market-leading conversion

    Pinwheel Secure: Authentication optimized for market-leading conversion

    Read more  ➔
    Pinwheelie Spotlight: Elena Churilova, Software Engineer, Integrations

    Pinwheelie Spotlight: Elena Churilova, Software Engineer, Integrations

    Read more  ➔
    May product release: Localization and downloadable pay stubs

    May product release: Localization and downloadable pay stubs

    Read more  ➔
    How a payroll API can level up lenders and renters

    How a payroll API can level up lenders and renters

    Read more  ➔
    The power of payroll APIs in consumer finance

    The power of payroll APIs in consumer finance

    Read more  ➔
    Data Talks: Pinwheel’s Fortune 1000 coverage and top employer trends

    Data Talks: Pinwheel’s Fortune 1000 coverage and top employer trends

    Read more  ➔
    April product release: Enabling connectivity to time and attendance data for 25M US workers

    April product release: Enabling connectivity to time and attendance data for 25M US workers

    Read more  ➔
    Tech spotlight: Increasing engineering momentum at a systems level

    Tech spotlight: Increasing engineering momentum at a systems level

    Read more  ➔
    How crypto exchanges can turn direct deposits into a fiat onramp

    How crypto exchanges can turn direct deposits into a fiat onramp

    Read more  ➔
    March product release: Time and attendance coverage and Pinwheel's new online home

    March product release: Time and attendance coverage and Pinwheel's new online home

    Read more  ➔
    Pinwheelie spotlight: Arianna Gelwicks, Tech Recruiting

    Pinwheelie spotlight: Arianna Gelwicks, Tech Recruiting

    Read more  ➔
    What is payroll data and how it benefits proptech companies

    What is payroll data and how it benefits proptech companies

    Read more  ➔
    Earned wage access: What is it and why does it matter?

    Earned wage access: What is it and why does it matter?

    Read more  ➔
    How fintech APIs are transforming financial services

    How fintech APIs are transforming financial services

    Read more  ➔
    Webinar: Unleash growth with income and payroll APIs

    Webinar: Unleash growth with income and payroll APIs

    Read more  ➔
    February product release: Updated Link UX and data quality

    February product release: Updated Link UX and data quality

    Read more  ➔
    Tech spotlight: Floating footer with React functional components

    Tech spotlight: Floating footer with React functional components

    Read more  ➔
    Why a direct deposit switching API is a must-have for banks and neobanks

    Why a direct deposit switching API is a must-have for banks and neobanks

    Read more  ➔
    Pinwheelie spotlight: Hale Ahangi, People Operations Lead

    Pinwheelie spotlight: Hale Ahangi, People Operations Lead

    Read more  ➔
    Shift from a vicious to virtuous cycle: The foundation for a fairer financial system

    Shift from a vicious to virtuous cycle: The foundation for a fairer financial system

    Read more  ➔
    January product release: Recurring access to income & employment

    January product release: Recurring access to income & employment

    Read more  ➔
    Pinwheel’s Series B and our path towards a fairer financial future

    Pinwheel’s Series B and our path towards a fairer financial future

    We're excited to share that we have raised a $50M Series B funding round led by GGV Capital with participation from many others.

    Read more  ➔
    Tech spotlight: How to implement async requests in your Python code

    Tech spotlight: How to implement async requests in your Python code

    Read more  ➔
    Pinwheelie spotlight: Devin DeCaro-Brown, Product Manager

    Pinwheelie spotlight: Devin DeCaro-Brown, Product Manager

    Read more  ➔
    2021 recap and product update: An amazing year for Pinwheel

    2021 recap and product update: An amazing year for Pinwheel

    Read more  ➔
    Charles Tsang joins Pinwheel as Head of Marketing

    Charles Tsang joins Pinwheel as Head of Marketing

    Read more  ➔
    Pinwheelie spotlight: Octavio Roscioli, Senior Software Engineer

    Pinwheelie spotlight: Octavio Roscioli, Senior Software Engineer

    Read more  ➔
    November product release: Beta launch of income & employment monitoring

    November product release: Beta launch of income & employment monitoring

    Read more  ➔
    How can payroll data help with one’s financial picture?

    How can payroll data help with one’s financial picture?

    Read more  ➔
    Pinwheelie spotlight: Caroline Lo, Software Engineer

    Pinwheelie spotlight: Caroline Lo, Software Engineer

    Read more  ➔
    2021 company onsite: Bringing Pinwheelies together

    2021 company onsite: Bringing Pinwheelies together

    Read more  ➔
    October product release: Beta launch of direct deposit allocation monitoring

    October product release: Beta launch of direct deposit allocation monitoring

    Read more  ➔
    Why payroll data access is inevitable on your product roadmap

    Why payroll data access is inevitable on your product roadmap

    Read more  ➔
    Security spotlight: SOC 2 compliance

    Security spotlight: SOC 2 compliance

    Read more  ➔
    Jeff Hudesman joins Pinwheel as Chief Information Security Officer

    Jeff Hudesman joins Pinwheel as Chief Information Security Officer

    Read more  ➔
    Welcoming John Whitfield, VP of Engineering

    Welcoming John Whitfield, VP of Engineering

    Read more  ➔
    Announcing Pinwheel’s FCRA Compliance

    Announcing Pinwheel’s FCRA Compliance

    Read more  ➔
    Pinwheel's statement on Section 1033

    Pinwheel's statement on Section 1033

    Read more  ➔
    Pinwheel raises $20M Series A

    Pinwheel raises $20M Series A

    Read more  ➔
    If I were a fintech founder

    If I were a fintech founder

    Read more  ➔