✅ We are only fixing critical bugs and security issues.
❌ No new features, enhancements, or non-critical updates will be added.
VWO’s FME product empowers teams to seamlessly test, release, optimize, and roll back features across their entire tech stack while minimizing risk and maximizing business impact.
💡 Need Help? For migration assistance or any questions, contact us at support@vwo.com
This open source library allows you to A/B Test your Website at server-side.
- Works with 2.2.10 onwards
gem install vwo-sdk
Importing and Instantiation
require 'vwo'
# Initialize client
vwo_client_instance = VWO.new(account_id, sdk_key)
# Initialize client with all parameters(explained in next section)
vwo_client_instance = VWO.new(account_id, sdk_key, custom_logger, UserStorage.new, true, settings_file)
# Get Settings
vwo_client_instance.get_settings
# Activate API
# With Custom Variables
options = { "custom_variable" => { "a" => "x"}}
variation_name = vwo_client_instance.activate(campaign_key, user_id, options)
# Without Custom Variables
options = {}
variation_name = vwo_client_instance.activate(campaign_key, user_id, options)
# GetVariation
# With Custom Variables
options = { "custom_variable" => { "a" => "x"}}
variation_name = vwo_client_instance.get_variation_name(campaign_key, user_id, options)
#Without Custom Variables
options = {}
variation_name = vwo_client_instance.get_variation_name(campaign_key, user_id, options)
# Track API
# With Custom Variables
options = { "custom_variable" => { "a" => "x"}}
is_successful = vwo_client_instance.track(campaign_key, user_id, goal_identifier, options)
# With Revenue Value
options = { "revenue_value" => 10.23}
is_successful = vwo_client_instance.track(campaign_key, user_id, goal_identifier, options)
# With both Custom Variables and Revenue Value
options = { "custom_variable" => { "a" => "x"}, "revenue_value" => 10.23}
is_successful = vwo_client_instance.track(campaign_key, user_id, goal_identifier, options)
# FeatureEnabled? API
# With Custom Varibles
options = { "custom_variable" => { "a" => "x"}}
is_successful = vwo_client_instance.feature_enabled?(campaign_key, user_id, options)
# Without Custom Variables
options = {}
is_successful = vwo_client_instance.feature_enabled?(campaign_key, user_id, options)
# GetFeatureVariableValue API
# With Custom Variables
options = { "custom_variable" => { "a" => "x"}}
variable_value = vwo_client_instance.get_feature_variable_value(campaign_key, variable_key, user_id, options)
# Without Custom Variables
options = {}
variable_value = vwo_client_instance.get_feature_variable_value(campaign_key, variable_key, user_id, options)
# Push API
is_successful = vwo_client_instance.push(tag_key, tag_value, user_id)
account_id
- Account for which sdk needs to be initializedsdk_key
- SDK key for that accountlogger
- If you need to pass your own logger. Check documentation belowUserStorage.new
- An object allowingget
andset
for maintaining user storagedevelopment_mode
- on/off (true/false). Default - falsesettings_file
- Settings file if already present during initialization. Its stringified JSON format.
API usage
User Defined Logger
There are two ways you can use your own custom logging
-
Override Existing Logging
class VWO::Logger def initialize(logger_instance) # Override this two create your own logging instance # Make sure log method is defined on it # i.e @@logger_instance = MyLogger.new(STDOUT) @@logger_instance = logger_instance || Logger.new(STDOUT) end # Override this method to handle logs in a custom manner def log(level, message) # Modify level & Message here # i.e message = "Custom message #{message}" @@logger_instance.log(level, message) end end
-
Pass your own logger during client initialization
vwo_client_instance = VWO.new(account_id, sdk_key, user_defined_logger)
Note - Make sure your logger instance has log
method which takes (level, message)
as arguments.
User Storage
Use custom UserStorage
```ruby
class VWO
# Abstract class encapsulating user storage service functionality.
# Override with your own implementation for storing
# And retrieving the user.
class UserStorage
# Abstract method, must be defined to fetch the
# User storage dict corresponding to the user_id.
#
# @param[String] :user_id ID for user that needs to be retrieved.
# @return[Hash] :user_storage_obj Object representing the user.
#
def get(user_id, campaign_key)
# example code to fetch it from DB column
JSON.parse(User.find_by(vwo_id: user_id).vwo_user)
end
# Abstract method, must be to defined to save
# The user dict sent to this method.
# @param[Hash] :user_storage_obj Object representing the user.
#
def set(user_data)
# example code to save it in DB
User.update_attributes(vwo_id: user_data.userId, vwo_user: JSON.generate(user_data))
end
end
end
# Now use it to initiate VWO client instance
vwo_client_instance = VWO.new(account_id, sdk_key, custom_logger, UserStorage.new)
```
Refer Official VWO Documentation
bundle exec rubocop lib
chmod +x ./start-dev.sh
bash start-dev.sh
gem install
ruby tests/test_all_tests.rb
Refer third-party-attributions.txt
Refer CHANGELOG.md
Please go through our contributing guidelines
Copyright 2019-2025 Wingify Software Pvt. Ltd.