This open source library allows you to A/B Test your Website at server-side.
- Works with NetStandard: 2.0 onwards.
PM> Install-Package VWO.Sdk
Using and Instantiation
using VWOSdk;
Settings settingsFile = VWO.GetSettingsFile(accountId, sdkKey); // Fetch settingsFile from VWO.
IVWOClient vwoClient = VWO.Launch(settingsFile); // Create VWO Client to user APIs.
API usage
using System.Collections.Generic;
// Activate API
// Without Custom Variable
public static Dictionary<string, dynamic> options = new Dictionary<string, dynamic>(){};
string variationName = vwoClient.Activate(campaignKey, userId, options);
// With Custom Variable , variation targeting variable
public readonly static Dictionary<string, dynamic> options = new Dictionary<string, dynamic>()
{
{
"customVariables", new Dictionary<string, dynamic>()
{
{"price", 100.1}
},
"variationTargetingVariables", new Dictionary<string, dynamic>()
{
{"team", "qa-internal"}
}
}
};
string variationName = vwoClient.Activate(campaignKey, userId, options);
// GetVariationName API
// Without Custom Variable
public static Dictionary<string, dynamic> options = new Dictionary<string, dynamic>(){};
string variationName = vwoClient.GetVariationName(campaignKey, userId, options);
// With Custom Variable snd variation targeting variable
public static Dictionary<string, dynamic> options = new Dictionary<string, dynamic>()
{
{
"customVariables", new Dictionary<string, dynamic>()
{
{"price", '40'}
}
"variationTargetingVariables", new Dictionary<string, dynamic>()
{
{"team", "qa-internal"}
}
}
};
string variationName = vwoClient.GetVariationName(campaignKey, userId, options);
// Track API
// For CUSTOM CONVERSION Goal
bool isSuccessful = vwoClient.Track(campaignKey, userId, goalIdentifier);
// For Goal Conversion in Multiple Campaign
Dictionary<string, bool> result = vwoClient.Track(List <string>() { campaignKey1 campaignKey2 }, userId, goalIdentifier);
// For Goal Conversion in All Possible Campaigns
Dictionary<string, bool> result = vwoClient.Track(userId, goalIdentifier);
// Without Revenue Value and Custom Variable
Dictionary<string, dynamic> options = new Dictionary<string, dynamic>(){};
bool isSuccessful = vwoClient.Track(campaignKey, userId, goalIdentifier, options);
// For only Revenue Value
public static Dictionary<string, dynamic> options = new Dictionary<string, dynamic>()
{
{ "revenueValue", 10.2 },
};
bool isSuccessful = vwoClient.Track(campaignKey, userId, goalIdentifier, options);
// For only Custom Variable
public static Dictionary<string, dynamic> options = new Dictionary<string, dynamic>()
{
{
"customVariables", new Dictionary<string, dynamic>()
{
{"location", 'India'}
}
}
};
bool isSuccessful = vwoClient.Track(campaignKey, userId, goalIdentifier, options);
// For Revenue Value and Custom Variable and Variation Targeting varaible
public static Dictionary<string, dynamic> options = new Dictionary<string, dynamic>()
{
{
"revenue_value", 10
},
{
"customVariables", new Dictionary<string, dynamic>()
{
{
"gender", "f"
}
}
},
{
"variationTargetingVariables", new Dictionary<string, dynamic>()
{
{
"abcd", 1
}
}
}
};
bool isSuccessful = vwoClient.Track(campaignKey, userId, goalIdentifier, options);
//IsFeatureEnabled API
//Without Custom Variable
public static Dictionary<string, dynamic> options = new Dictionary<string, dynamic>(){};
bool isSuccessful = vwo.Client.IsFeatureEnabled(campaignKey, userId, options);
//With Custom Variable
public static Dictionary<string, dynamic> options = new Dictionary<string, dynamic>()
{
{
"customVariables", new Dictionary<string, dynamic>()
{
{"value", 10}
}
}
};
bool isSuccessful = vwo.Client.IsFeatureEnabled(campaignKey, userId, options);
//GetFeatureVariableValue API
//Without Custom Variable
Dictionary<string, dynamic> options = new Dictionary<string, dynamic>(){};
dynamic variableValue = vwo.Client.GetFeatureVariableValue(campaignKey, variableKey, userId, options);
//With Custom Variable
public static Dictionary<string, dynamic> options = new Dictionary<string, dynamic>()
{
{
"customVariables", new Dictionary<string, dynamic>()
{
{"value", 10}
}
}
};
dynamic variableValue = vwo.Client.GetFeatureVariableValue(campaignKey, variableKey, userId, options);
//Push API
bool isSuccessful = vwo.Client.Push(tagKey, tagValue, userId);
//Pass TagKey
var TagKey = "abc";
bool isSuccessful = vwo.Client.Push(TagKey, tagValue, userId);
//Pass TagValue
var TagValue = "abc";
bool isSuccessful = vwo.Client.Push(tagKey, TagValue, userId);
Configure Log Level
VWO.Configure(LogLevel.DEBUG);
Implement and Configure Custom Logger - implement your own logger class
using VWOSdk;
public class CustomLogWriter : ILogWriter
{
public void WriteLog(LogLevel logLevel, string message)
{
// ...write to file or database or integrate with any third-party service
}
}
// Configure Custom Logger with SDK.
VWO.Configure(new CustomLogWriter());
User Storage Service
using VWOSdk;
public class UserStorageService : IUserStorageService
{
public UserStorageMap Get(string userId)
{
// ...code here for getting data
// return data
}
public void Set(UserStorageMap userStorageMap)
{
// ...code to persist data
}
}
var settingsFile = VWO.GetSettingsFile(VWOConfig.AccountId, VWOConfig.SdkKey);
// Provide UserStorageService instance while vwoClient Instantiation.
var vwoClient = VWO.Launch(settingsFile, userStorageService: new UserStorageService());
// Set specific goalType to Track
// Available GoalTypes - GoalTypes.REVENUE, GoalTypes.CUSTOM, GoalTypes.ALL (Default)
var vwoClient = VWO.Launch(settingsFile, goalTypeToTrack: Constants.GoalTypes.REVENUE);
// Set if a return user should be tracked, default false
var vwoClient = VWO.Launch(settingsFile, shouldTrackReturningUser: true);
Refer Official VWO Documentation
chmod +x start-dev.sh;
bash start-dev.sh;
It will install the git-hooks necessary for commiting and pushing the code. Commit-messages follow a guideline. All test cases must pass before pushing the code.
dotnet test
Refer third-party-attributions.txt
- Main Contributor - Sidhant Gakhar
- Repo health maintainer - Varun Malhotra(@s0ftvar)
Refer CHANGELOG.md
Please go through our contributing guidelines
Copyright 2019-2021 Wingify Software Pvt. Ltd.