- Instead of tuple-lists, this library uses actual tuples
- Comparisons with
undefinedare implemented by using:undefined - Function names are converted to
snake_case, andis_prefix is replaced with a?suffix - Instead of classes, a Context struct is used (similar to
%Plug.Conn{}inplug)
Installation
Addgrowthbook to your list of dependencies in mix.exs:
Quick Start
Get started with GrowthBook in just a few steps:Automatic Features Refresh
The Elixir SDK provides a GenServer-based feature repository that automatically fetches and caches features from the GrowthBook API.Initialization Options
Refresh Strategies
The SDK supports two refresh strategies:Periodic Refresh (Default)
Features are automatically refreshed in the background based on the TTL:Manual Refresh
Features are only refreshed when explicitly requested:Supervision Tree Integration
For production applications, add theFeatureRepository to your application’s supervision tree:
Graceful Shutdown
When your application shuts down, stop the FeatureRepository GenServer:Encryption & Security
The Elixir SDK supports encrypted feature payloads and secure attribute hashing to protect sensitive data.Encrypted Features
Encrypted features ensure that sensitive feature configurations are never exposed in plain text:- Enable “Encrypt SDK Payload” in your SDK Connection settings
- Copy the encryption key from your SDK Connection
- Store it securely in environment variables
- Pass it to
GrowthBook.init/1
Secure Attributes
When secure attribute hashing is enabled, you can safely target users based on sensitive attributes like email or phone numbers without exposing the actual values.Setup
Enable secure attribute hashing in your SDK Connection, then hash sensitive attributes before passing them to GrowthBook:Usage
Security Best Practices
- Never commit encryption keys or salts to version control
- Use different keys for each environment (dev, staging, production)
- Rotate keys regularly and coordinate updates across all systems
- Monitor decryption failures which may indicate key rotation issues
- Use secrets management tools like Vault, AWS Secrets Manager, or similar
Using Features
Once GrowthBook is initialized, you can evaluate features and run experiments.Feature Evaluation
Feature Result Properties
TheGrowthBook.feature/2 function returns a result with these properties:
Running Inline Experiments
You can run experiments directly without defining them as features:Experiment Configuration
TheExperiment struct supports these properties:
Experiment Result
The experiment result contains detailed information:Tracking Experiments
The SDK doesn’t include built-in tracking callbacks, but you can implement tracking by checking experiment results:User Attributes
Attributes are used for targeting and experiment assignment:- Use consistent naming conventions (snake_case or camelCase)
- Keep attribute values simple and serializable
- Document custom attributes for your team
- Consider attribute cardinality for targeting efficiency
Context Struct
TheGrowthBook.Context struct is the core data structure:

