Using A/B Testing you can create different tests and their variants to take informed decisions and track conversions in your app. You can define distribution rules to test variants and can choose your best performing variant as a winner.
import com.shephertz.app42.paas.sdk.android.App42API; import com.shephertz.app42.paas.sdk.android.ServiceAPI; import com.shephertz.app42.paas.sdk.android.abtest.ABTest; import com.shephertz.app42.paas.sdk.android.abtest.ABTestService; import com.shephertz.app42.paas.sdk.android.App42BadParameterException; import com.shephertz.app42.paas.sdk.android.App42NotFoundException;using com.shephertz.app42.paas.sdk.windows; using com.shephertz.app42.paas.sdk.windows.abtest;#import "Shephertz_App42_iOS_API/Shephertz_App42_iOS_API.h"#import "Shephertz_App42_iOS_API/Shephertz_App42_iOS_API.h"import com.shephertz.app42.paas.sdk.java.App42BadParameterException; import com.shephertz.app42.paas.sdk.java.App42NotFoundException; import com.shephertz.app42.paas.sdk.java.App42API; import com.shephertz.app42.paas.sdk.java.abtest.ABTest; import com.shephertz.app42.paas.sdk.java.abtest.ABTestService;using com.shephertz.app42.paas.sdk.csharp; using com.shephertz.app42.paas.sdk.csharp.abtest;<script type="text/javascript" src="App42-all-x.x.x.min.js">Coming SoonComing Soonusing com.shephertz.app42.paas.sdk.csharp; using com.shephertz.app42.paas.sdk.csharp.abtest;include_once '../App42Response.php'; include_once '../App42Exception.php'; include_once '../App42BadParameterException.php'; include_once '../App42NotFoundException.php'; include_once '../App42Log.php'; include_once '../ABTestService.php';Not AvailableNot Availableimport com.shephertz.app42.paas.sdk.as3.App42CallBack; import com.shephertz.app42.paas.sdk.as3.App42API; import com.shephertz.app42.paas.sdk.as3.App42Response; import com.shephertz.app42.paas.sdk.as3.App42Exception; import com.shephertz.app42.paas.sdk.as3.App42BadParameterException; import com.shephertz.app42.paas.sdk.as3.App42NotFoundException; import com.shephertz.app42.paas.sdk.as3.abtest.ABTest; import com.shephertz.app42.paas.sdk.as3.abtest.ABTestService; import com.shephertz.app42.paas.sdk.as3.abtest.Variant; import com.shephertz.app42.paas.sdk.as3.util.Util;Not Availableimport com.shephertz.app42.paas.sdk.java.App42BadParameterException; import com.shephertz.app42.paas.sdk.java.App42NotFoundException; import com.shephertz.app42.paas.sdk.java.App42API; import com.shephertz.app42.paas.sdk.java.abtest.ABTest; import com.shephertz.app42.paas.sdk.java.abtest.ABTestService;
In order to use the various functions available in a specific API, the developer has to initialize with App42API by passing the apiKey and the secretKey which will become available after the app creation from AppHQ dashboard.
Required Parameters
apiKey - The Application key given when the application was created.
secretKey - The secret key corresponding to the application key given when the application was created.
App42API.initialize("ANDROID_APPLICATION_CONTEXT","API_KEY","SECRET_KEY");App42API.Initialize("API_KEY","SECRET_KEY");[App42API initializeWithAPIKey:@"APP_KEY" andSecretKey:@"SECRET_KEY"];App42API.initializeWithAPIKey("API_KEY", andSecretKey:"SECRET_KEY")App42API.initialize("API_KEY","SECRET_KEY");App42API.Initialize("API_KEY","SECRET_KEY");App42.initialize("API_KEY","SECRET_KEY");App42API:initialize("API_KEY","SECRET_KEY");App42API::Initialize("API_KEY", "SECRET_KEY");App42API.Initialize("API_KEY","SECRET_KEY");App42API::initialize("API_KEY","SECRET_KEY");App42API::Initialize("API_KEY", "SECRET_KEY");api = App42::ServiceAPI.new("API_KEY","SECRET_KEY")App42API.initialize("API_KEY","SECRET_KEY");Coming SoonApp42API.initialize("API_KEY","SECRET_KEY");
After initialization, the developer will have to call the buildXXXService method on App42API to get the instance of the particular API that they wish to build. For example, to build an instance of ABTestService, buildABTestService() method needs to be called.
ABTestService abTestService = App42API.buildABTestService();ABTestService abTestService = App42API.BuildABTestService();ABTestService *abTestService = [App42API buildABTestService];let abTestService = App42API.buildABTestService as! ABTestServiceABTestService abTestService = App42API.buildABTestService();ABTestService abTestService = App42API.BuildABTestService();var abTestService = new App42ABTest();Coming SoonComing SoonABTestService abTestService = App42API.BuildABTestService();$abTestService = App42API::buildABTestService();Not AvailableNot Availablevar abTestService:ABTestService = App42API.buildABTestService();Not AvailableABTestService abTestService = App42API.buildABTestService();
Execute given test and return variant and its profile from server based on distribution rule defined in the test.
Required Parameters
testName - Name of the test which is to be executed.
String testName="<Enter the testName>"; App42API.initialize("ANDROID_APPLICATION_CONTEXT","API_KEY","SECRET_KEY"); ABTestService abTestService = App42API.buildABTestService(); abTestService.execute(testName, new App42CallBack() { public void onSuccess(Object response) { ABTest abTest = (ABTest)response; System.out.println("Test Name is : "+abTest.getName()); System.out.println("Type is :" +abTest.getType()); System.out.println("Is Active : "+abTest.isActive()); for(int i=0;i<abTest.getVariantList().size();i++) { System.out.println("Variant Name : "+abTest.getVariantList().get(i).getName()); System.out.println("get profile list : "+abTest.getVariantList().get(i).getProfileJSON()); } } public void onException(Exception ex) { System.out.println("Exception Message"+ex.getMessage()); } });String testName="<Enter the testName>"; App42API.Initialize("API_KEY","SECRET_KEY"); ABTestService abTestService = App42API.BuildABTestService(); abTestService.Execute(testName, new Callback()); public class Callback : App42Callback { public void OnException(App42Exception exception) { Console.WriteLine("Exception Message" + exception); } public void OnSuccess(Object response) { ABTest abTest = (ABTest) response; Console.WriteLine("Test Name is : " + abTest.GetName()); Console.WriteLine("Type is :" + abTest.GetType()); Console.WriteLine("Is Active : " + abTest.IsActive()); for (int i = 0; i < abTest.GetVariantList().Count; i++) { Console.WriteLine("Name : " + abTest.GetVariantList()[i].GetName()); Console.WriteLine("Get profile list : " + abTest.GetVariantList()[i].GetProfileJSON()); } } }NSString *testName = @"<Enter the testName>"; [App42API initializeWithAPIKey:@"APP_KEY" andSecretKey:@"SECRET_KEY"]; ABTestService *abTestService = [App42API buildABTestService]; [abTestService execute:testName completionBlock:^(BOOL success, id responseObj, App42Exception *exception) { if (success) { ABTest *abTest = (ABTest*)responseObj; NSLog(@"Name =%@",abTest.name); NSMutableArray *variantList = abTest.variantList; for(Variant *variant in variantList) { NSLog(@"Name is = %@ " , variant.name); NSLog(@"get profile list is = %@ " , variant.profile); } NSLog(@"Type is %@",abTest.type); } else { NSLog(@"Exception = %@",[exception reason]); NSLog(@"HTTP error Code = %d",[exception httpErrorCode]); NSLog(@"App Error Code = %d",[exception appErrorCode]); NSLog(@"User Info = %@",[exception userInfo]); } }];let testName = "<Enter the testName>" App42API.initializeWithAPIKey("API-KEY", andSecretKey: "SECRET_KEY") let abTestService = App42API.buildABTestService as! ABTestService abTestService?.execute(testName, completionBlock:{ (success, response, exception) -> Void in if (success) { let abTest = response as! ABTest NSLog("Name =%@",abTest.name) var variantList:NSMutableArray = NSMutableArray() variantList = abTest.variantList for variant in variantList { NSLog("Name is = %@ " , variant.name) } NSLog("Type is %@",abTest.type) } else { NSLog("%@", exception.reason!) NSLog("%d", exception.appErrorCode) NSLog("%d", exception.httpErrorCode) NSLog("%@", exception.userInfo!) } })String testName="<Enter the testName>"; App42API.initialize("API_KEY","SECRET_KEY"); ABTestService abTestService = App42API.buildABTestService(); ABTest abTest=abTestService.execute(testName); System.out.println("Test Name is : "+abTest.getName()); System.out.println("Type is :" +abTest.getType()); System.out.println("Is Active : "+abTest.isActive()); for(int i=0;i<abTest.getVariantList().size();i++) { System.out.println("Variant Name : "+abTest.getVariantList().get(i).getName()); System.out.println("Get profile list : "+abTest.getVariantList().get(i).getProfileJSON()); }String testName="<Enter the testName>"; App42Log.SetDebug(true); //Prints output in your editor console App42API.Initialize("API_KEY","SECRET_KEY"); ABTestService abTestService = App42API.BuildABTestService(); abTestService.Execute(testName, new UnityCallBack()); public class UnityCallBack : App42CallBack { public void OnSuccess(object response) { ABTest abTest = (ABTest)response; App42Log.Console("Test Name : " + abTest.GetName()); for (int i=0; i < abTest.GetVariantList().Count; i++) { App42Log.Console("Variant Name : " + abTest.GetVariantList()[i].GetName()); App42Log.Console("ProfileJSON : " + abTest.GetVariantList()[i].GetProfileJSON()); } } public void OnException(Exception e) { App42Log.Console("Exception : " + e); } }var testName = "<Enter the testName>", abTestObj; App42.initialize("API_KEY","SECRET_KEY"); var abTestService = new App42ABTest(); abTestService.execute(testName,{ success: function(object) { var result = JSON.parse(object); abTestObj = result.app42.response.abtest; console.log("Test Name : " + abTestObj.name); console.log("Variant Name is : " + abTestObj.variant.name); }, error: function(error) { console.log("Exception is : " + error) } });Coming SoonComing SoonString testName="<Enter the testName>"; App42API.Initialize("API_KEY","SECRET_KEY"); ABTestService abTestService = App42API.BuildABTestService(); ABTest abTest = abTestService.Execute(testName); Console.WriteLine("Test Name is : " + abTest.GetName()); Console.WriteLine("Type is :" + abTest.GetType()); Console.WriteLine("Is Active : " + abTest.IsActive()); for(int i=0; i < abTest.getVariantList().Count; i++) { Console.WriteLine("Variant Name : "+abTest.GetVariantList()[i].GetName()); Console.WriteLine("Get profile list : "+abTest.GetVariantList()[i].GetProfileJSON()); }$testName="<Enter the testName>"; App42API::initialize("API_KEY","SECRET_KEY"); $abTestService = App42API::buildABTestService(); $abTest = $abTestService->execute($testName); print_r("Test Name is : ".$abTest->getName()); print_r("Is Active : " .$abTest->isActive()); print_r("Type is :".$abTest->getType()); $variant = $abTest->getVariantList(); foreach ($variant as $variantList) { print_r("Variant Name : ".$variantList->getName()); print_r(json_encode($variantList->getProfileJSON())); }Not AvailableNot Availablevar testName:String="<Enter the testName>"; App42API.initialize("API_KEY","SECRET_KEY"); var abTestService:ABTestService = App42API.buildABTestService(); abTestService.execute(testName,new callback()); class callback implements App42CallBack { public function onException(exception:App42Exception):void { trace("Exception Message " + exception); } public function onSuccess(response:Object):void { if(response is ABTest) { var abtest:ABTest = ABTest(response); trace("Test Name is : "+abtest.getName()); trace("Type is :" +abtest.getType()); trace("Is Active : "+abtest.IsActive()); for(var i:int=0;i<abtest.getVariantList().length;i++) { trace("Variant Name : "+abtest.getVariantList()[i].getName()); var object:Object = com.adobe.serialization.json.JSON.decode(Variant(abtest.getVariantList()[i]).getProfileJSON()); trace("get profile list : "+Util.toString(object)); } } } }Not AvailableString testName="<Enter the testName>"; ABTest abTest=abTestService.execute(testName); System.out.println("Test Name is : "+ abTest.getName()); System.out.println("Type is :" + abTest.getType()); System.out.println("Is Active : "+ abTest.isActive()); App42API.initialize("API_KEY","SECRET_KEY"); ABTestService abTestService = App42API.buildABTestService(); Vector variantList = abTest.getVariantList(); for(int i=0;i<variantList.size();i++) { System.out.println("Name : " + ((ABTest.Variant)variantList.elementAt(i)).getName()); System.out.println("get profile list : "+ ((ABTest.Variant)variantList.elementAt(i)).getProfileJSON()); }
Goal achieved for the given test case variant.
Required Parameters
testName - Name of the test for which goal is to be achieved.
variantName - Name of the variant in test for which goal is to be achieved.
String testName="<Enter the testName>"; String variantName="<Name Of the variant>"; App42API.initialize("ANDROID_APPLICATION_CONTEXT","API_KEY","SECRET_KEY"); ABTestService abTestService = App42API.buildABTestService(); abTestService.goalAchieved(testName,variantName,new App42CallBack() { public void onSuccess(Object response) { ABTest abTest = (ABTest)response; System.out.println("Test Name is : "+abTest.getName()); System.out.println("Type is :" +abTest.getType()); System.out.println("Is Active : "+abTest.isActive()); for(int i=0;i<abTest.getVariantList().size();i++) { System.out.println("Variant Name : "+abTest.getVariantList().get(i).getName()); System.out.println("get profile list : "+abTest.getVariantList().get(i).getProfileJSON()); } } public void onException(Exception ex) { System.out.println("Exception Message " + ex.getMessage()); } });String testName="<Enter the testName>"; String variantName="<Name Of the variant>"; App42API.Initialize("API_KEY","SECRET_KEY"); ABTestService abTestService = App42API.BuildABTestService(); abTestService.GoalAchieved(testName, variantName, new Callback()); public class Callback : App42Callback { public void OnException(App42Exception exception) { Console.WriteLine("Exception Message" + exception.GetMessage()); } public void OnSuccess(Object response) { ABTest abTest = (ABTest) response; Console.WriteLine("Test Name is : " + abTest.GetName()); Console.WriteLine("Type is :" + abTest.GetType()); Console.WriteLine("Is Active : " + abTest.IsActive()); for (int i = 0; i < abTest.GetVariantList().Count; i++) { Console.WriteLine("Name : " + abTest.GetVariantList()[i].GetName()); Console.WriteLine("Get profile list : " + abTest.GetVariantList()[i].GetProfileJSON()); } } }NSString *testName = @"<Enter the testName>"; NSString *variant = @"<Name Of the variant>"; [App42API initializeWithAPIKey:@"APP_KEY" andSecretKey:@"SECRET_KEY"]; ABTestService *abTestService = [App42API buildABTestService]; [abTestService goalAchievedForTest:testName withVariant:variant completionBlock:^(BOOL success, id responseObj, App42Exception *exception) { if (success) { ABTest *abTest = (ABTest*)responseObj; NSLog(@"Name =%@",abTest.name); NSMutableArray *variantList = abTest.variantList; for(Variant *variant in variantList) { NSLog(@"Name is = %@ " , variant.name); NSLog(@"get profile list is = %@ " , variant.profile); } NSLog(@"Type is %@",abTest.type); } else { NSLog(@"Exception = %@",[exception reason]); NSLog(@"HTTP error Code = %d",[exception httpErrorCode]); NSLog(@"App Error Code = %d",[exception appErrorCode]); NSLog(@"User Info = %@",[exception userInfo]); } }];let testName = "<Enter the testName>" App42API.initializeWithAPIKey("API-KEY", andSecretKey: "SECRET_KEY") let abTestService = App42API.buildABTestService as! ABTestService abTestService?.executeDataDriven(testName, completionBlock:{ (success, response, exception) -> Void in if (success) { let abTest = response as! ABTest NSLog("Name =%@",abTest.name) var variantList:NSMutableArray = NSMutableArray() variantList = abTest.variantList for variant in variantList { NSLog("Name is = %@ " , variant.name) } NSLog("Type is %@",abTest.type) } else { NSLog("%@", exception.reason!) NSLog("%d", exception.appErrorCode) NSLog("%d", exception.httpErrorCode) NSLog("%@", exception.userInfo!) } })String testName="<Enter the testName>"; String variantName="<Name Of the variant>"; App42API.initialize("API_KEY","SECRET_KEY"); ABTestService abTestService = App42API.buildABTestService(); ABTest abTest=abTestService.goalAchieved(testName, variantName); System.out.println("Test Name is : "+abTest.getName()); System.out.println("Type is :" +abTest.getType()); System.out.println("Is Active : "+abTest.isActive()); for(int i=0;i<abTest.getVariantList().size();i++) { System.out.println("Variant Name : "+abTest.getVariantList().get(i).getName()); System.out.println("Get profile list : "+abTest.getVariantList().get(i).getProfileJSON()); }String testName="<Enter the testName>"; String variantName="<Name Of the variant>"; App42Log.SetDebug(true); //Prints output in your editor console App42API.Initialize("API_KEY","SECRET_KEY"); ABTestService abTestService = App42API.BuildABTestService(); abTestService.GoalAchieved(testName, variantName, new UnityCallBack()); public class UnityCallBack : App42CallBack { public void OnSuccess(object response) { ABTest abTest = (ABTest)response; App42Log.Console("Test Name : " + abTest.GetName()); for (int i=0; i < abTest.GetVariantList().Count; i++) { App42Log.Console("Variant Name : " + abTest.GetVariantList()[i].GetName()); App42Log.Console("ProfileJSON : " + abTest.GetVariantList()[i].GetProfileJSON()); } } public void OnException(Exception e) { App42Log.Console("Exception : " + e); } }var testName = "<Enter the testName>", variantName="<Name Of the variant>", abTestObj; App42.initialize("API_KEY","SECRET_KEY"); var abTestService = new App42ABTest(); abTestService.goalAchieved(testName, variantName,{ success: function(object) { var result = JSON.parse(object); abTestObj = result.app42.response.abtest; console.log("Test Name : " + abTestObj.name); console.log("Variant Name is : " + abTestObj.variant.name); console.log("ProfileJSON is : " + JSON.stringify(abTestObj.variant.profile)); }, error: function(error) { console.log("Exception is : " + error) } });Coming SoonComing SoonString testName="<Enter the testName>"; String variantName="<Name Of the variant>"; App42API.Initialize("API_KEY","SECRET_KEY"); ABTestService abTestService = App42API.BuildABTestService(); ABTest abTest=abTestService.GoalAchieved(testName, variantName); Console.WriteLine("Test Name is : " + abTest.GetName()); Console.WriteLine("Type is :" + abTest.GetType()); Console.WriteLine("Is Active : " + abTest.IsActive()); for(int i=0; i < abTest.getVariantList().Count; i++) { Console.WriteLine("Variant Name : "+abTest.GetVariantList()[i].GetName()); Console.WriteLine("Get profile list : "+abTest.GetVariantList()[i].GetProfileJSON()); }$testName="<Enter the testName>"; $variantName="<Name Of the variant>"; App42API::initialize("API_KEY","SECRET_KEY"); $abTestService = App42API::buildABTestService(); $abTest = $abTestService->goalAchieved($testName, $variantName); print_r("Test Name is : ". $abTest->getName() ); print_r("Is Active : ".$abTest->isActive() ); print_r("Type is :".$abTest->getType() ); $variant = $abTest->getVariantList(); foreach ($variant as $variantList) { print_r("Variant Name : ".$variantList->getName() ); print_r(json_encode($variantList->getProfileJSON())); }Not AvailableNot Availablevar testName:String="<Enter the testName>"; var variantName:String="<Name Of the variant>"; App42API.initialize("API_KEY","SECRET_KEY"); var abTestService:ABTestService = App42API.buildABTestService(); abTestService.goalAchieved(testName, variantName, new callback()); class callback implements App42CallBack { public function onException(exception:App42Exception):void { trace("Exception Message " + exception); } public function onSuccess(response:Object):void { if(response is ABTest) { var abtest:ABTest = ABTest(response); trace("Test Name is : "+abtest.getName()); trace("Type is :" +abtest.getType()); trace("Is Active : "+abtest.IsActive()); for(var i:int=0;i<abtest.getVariantList().length;i++) { trace("Variant Name : "+abtest.getVariantList()[i].getName()); var object:Object = com.adobe.serialization.json.JSON.decode(Variant(abtest.getVariantList()[i]).getProfileJSON()); trace("get profile list : "+Util.toString(object)); } } } }Not AvailableString testName="<Enter the testName>"; String variantName="<Name Of the variant>"; App42API.initialize("API_KEY","SECRET_KEY"); ABTestService abTestService = App42API.buildABTestService(); ABTest abTest = abTestService.goalAchieved(testName, variantName); System.out.println("Test Name is : "+ abTest.getName()); System.out.println("Type is :" + abTest.getType()); System.out.println("Is Active : "+ abTest.isActive()); Vector variantList = abTest.getVariantList(); for(int i=0;i<variantList.size();i++) { System.out.println("Name " + ((ABTest.Variant)variantList.elementAt(i)).getName()); System.out.println("Get profile list : "+ ((ABTest.Variant)variantList.elementAt(i)).getProfileJSON()); }
Execute given data driven test case and return variant profile from server.
testName - Name of the test which is to be executed.
String testName="<Enter the testName>"; App42API.initialize("ANDROID_APPLICATION_CONTEXT","API_KEY","SECRET_KEY"); ABTestService abTestService = App42API.buildABTestService(); abTestService.executeDataDriven(testName,new App42CallBack() { public void onSuccess(Object response) { ABTest abTest = (ABTest)response; System.out.println("Test Name is : "+abTest.getName()); System.out.println("Type is :" +abTest.getType()); System.out.println("Is Active : "+abTest.isActive()); for(int i=0;i<abTest.getVariantList().size();i++) { System.out.println("Variant Name : "+abTest.getVariantList().get(i).getName()); System.out.println("get profile list : "+abTest.getVariantList().get(i).getProfileJSON()); } } public void onException(Exception ex) { System.out.println("Exception Message"+ex.getMessage()); } });String testName="<Enter the testName>"; App42API.Initialize("API_KEY","SECRET_KEY"); ABTestService abTestService = App42API.BuildABTestService(); abTestService.ExecuteDataDriven(testName, new Callback()); public class Callback : App42Callback { public void OnException(App42Exception exception) { Console.WriteLine("Exception Message" + exception.GetMessage()); } public void OnSuccess(Object response) { ABTest abTest = (ABTest) response; Console.WriteLine("Test Name is : " + abTest.GetName()); Console.WriteLine("Type is :" + abTest.GetType()); Console.WriteLine("Is Active : " + abTest.IsActive()); for (int i = 0; i < abTest.GetVariantList().Count; i++) { Console.WriteLine("Name : " + abTest.GetVariantList()[i].GetName()); Console.WriteLine("Get profile list : " + abTest.GetVariantList()[i].GetProfileJSON()); } } }NSString *testName = @"<Enter the testName>"; [App42API initializeWithAPIKey:@"APP_KEY" andSecretKey:@"SECRET_KEY"]; ABTestService *abTestService = [App42API buildABTestService]; [abTestService executeDataDriven:testName completionBlock:^(BOOL success, id responseObj, App42Exception *exception) { if (success) { ABTest *abTest = (ABTest*)responseObj; NSLog(@"Name =%@",abTest.name); NSMutableArray *variantList = abTest.variantList; for(Variant *variant in variantList) { NSLog(@"Name is = %@ " , variant.name); NSLog(@"get profile list is = %@ " , variant.profile); } NSLog(@"Type is %@",abTest.type); } else { NSLog(@"Exception = %@",[exception reason]); NSLog(@"HTTP error Code = %d",[exception httpErrorCode]); NSLog(@"App Error Code = %d",[exception appErrorCode]); NSLog(@"User Info = %@",[exception userInfo]); } }];let testName = "<Enter the testName>" App42API.initializeWithAPIKey("API-KEY", andSecretKey: "SECRET_KEY") let abTestService = App42API.buildABTestService as! ABTestService abTestService?.isActive(testName, completionBlock:{ (success, response, exception) -> Void in if (success) { let isActive = response as! NSNumber NSLog("isActive %@", isActive) } else { NSLog("%@", exception.reason!) NSLog("%d", exception.appErrorCode) NSLog("%d", exception.httpErrorCode) NSLog("%@", exception.userInfo!) } })String testName="<Enter the testName>"; App42API.initialize("API_KEY","SECRET_KEY"); ABTestService abTestService = App42API.buildABTestService(); ABTest abTest = abTestService.executeDataDriven(testName); System.out.println("Test Name is : " + abTest.getName()); System.out.println("Type is :" + abTest.getType()); System.out.println("Is Active : " + abTest.isActive()); for(int i=0;i<abTest.getVariantList().size();i++) { System.out.println("Variant Name : "+abTest.getVariantList().get(i).getName()); System.out.println("get profile list : "+abTest.getVariantList().get(i).getProfileJSON()); }String testName="<Enter the testName>"; App42Log.SetDebug(true); //Prints output in your editor console App42API.Initialize("API_KEY","SECRET_KEY"); ABTestService abTestService = App42API.BuildABTestService(); abTestService.ExecuteDataDriven(testName, new UnityCallBack()); public class UnityCallBack : App42CallBack { public void OnSuccess(object response) { ABTest abTest = (ABTest)response; App42Log.Console("Test Name : " + abTest.GetName()); for (int i=0; i < abTest.GetVariantList().Count; i++) { App42Log.Console("Variant Name : " + abTest.GetVariantList()[i].GetName()); App42Log.Console("ProfileJSON : " + abTest.GetVariantList()[i].GetProfileJSON()); } } public void OnException(Exception e) { App42Log.Console("Exception : " + e); } }var testName = "<Enter the testName>", abTestObj; App42.initialize("API_KEY","SECRET_KEY"); var abTestService = new App42ABTest(); abTestService.executeDataDriven(testName,{ success: function(object) { var result = JSON.parse(object); abTestObj = result.app42.response.abtest; console.log("Test Name : " + abTestObj.name); console.log("Variant Name is : " + abTestObj.variant.name); console.log("ProfileJSON is : " + JSON.stringify(abTestObj.variant.profile)); }, error: function(error) { console.log("Exception is : " + error) } });Coming SoonComing SoonString testName="<Enter the testName>"; App42API.Initialize("API_KEY","SECRET_KEY"); ABTestService abTestService = App42API.BuildABTestService(); ABTest abTest = abTestService.ExecuteDataDriven(testName); Console.WriteLine("Test Name is : " + abTest.GetName()); Console.WriteLine("Type is :" + abTest.GetType()); Console.WriteLine("Is Active : " + abTest.IsActive()); for(int i=0; i < abTest.getVariantList().Count; i++) { Console.WriteLine("Variant Name : "+abTest.GetVariantList()[i].GetName()); Console.WriteLine("Get profile list : "+abTest.GetVariantList()[i].GetProfileJSON()); }$testName="<Enter the testName>"; App42API::initialize("API_KEY","SECRET_KEY"); $abTestService = App42API::buildABTestService(); $abTest = $abTestService->executeDataDriven($testName); print_r("Test Name is : ".$abTest->getName() ); print_r("Is Active : ".$abTest->isActive() ); print_r("Type is :".$abTest->getType() ); $variant = $abTest->getVariantList(); foreach ($variant as $variantList) { print_r("Variant Name : ".$variantList->getName() ); print_r(json_encode($variantList->getProfileJSON())); }Not AvailableNot Availablevar testName:String="<Enter the testName>"; App42API.initialize("API_KEY","SECRET_KEY"); var abTestService:ABTestService = App42API.buildABTestService(); abTestService.executeDataDriven(testName,new callback()); class callback implements App42CallBack { public function onException(exception:App42Exception):void { trace("Exception Message " + exception); } public function onSuccess(response:Object):void { if(response is ABTest) { var abtest:ABTest = ABTest(response); trace("Test Name is : "+abtest.getName()); trace("Type is :" +abtest.getType()); trace("Is Active : "+abtest.IsActive()); for(var i:int=0;i<abtest.getVariantList().length;i++) { trace("Variant Name : "+abtest.getVariantList()[i].getName()); var object:Object = com.adobe.serialization.json.JSON.decode(Variant(abtest.getVariantList()[i]).getProfileJSON()); trace("get profile list : "+Util.toString(object)); } } } }Not AvailableString testName="<Enter the testName>"; App42API.initialize("API_KEY","SECRET_KEY"); ABTestService abTestService = App42API.buildABTestService(); ABTest abTest = abTestService.executeDataDriven(testName); System.out.println("Test Name is : " + abTest.getName()); System.out.println("Type is :" + abTest.getType()); System.out.println("Is Active : " + abTest.isActive()); Vector variantList = abTest.getVariantList(); for(int i=0;i<variantList.size();i++){ System.out.println("Name " + ((ABTest.Variant)variantList.elementAt(i)).getName()); System.out.println("Get profile list : "+ ((ABTest.Variant)variantList.elementAt(i)).getProfileJSON()); }
Required Parameters
testName - Name of the test for which goal is to achieved.
variantName - Name of the variant in test for which goal is to achieved.
String testName="<Enter the testName>"; String variantName="<Name Of the variant>"; App42API.initialize("ANDROID_APPLICATION_CONTEXT","API_KEY","SECRET_KEY"); ABTestService abTestService = App42API.buildABTestService(); abTestService.getProfileData(testName,variantName,new App42CallBack() { public void onSuccess(Object response) { ABTest abTest = (ABTest)response; System.out.println("Test Name is : "+abTest.getName()); System.out.println("Type is :" +abTest.getType()); System.out.println("Is Active : "+abTest.isActive()); for(int i=0;i<abTest.getVariantList().size();i++) { System.out.println("Variant Name : "+abTest.getVariantList().get(i).getName()); System.out.println("get profile list : "+abTest.getVariantList().get(i).getProfileJSON()); } } public void onException(Exception ex) { System.out.println("Exception Message " + ex.getMessage()); } });Coming SoonComing Soonlet testName = "<Enter the testName>" let variant = "<Name Of the variant>" App42API.initializeWithAPIKey("API-KEY", andSecretKey: "SECRET_KEY") let abTestService = App42API.buildABTestService as! ABTestService abTestService?.goalAchievedForTest(testName, withVariant:variant, completionBlock:{ (success, response, exception) -> Void in if (success) { let abTest = response as! ABTest NSLog("Name =%@",abTest.name); var variantList:NSMutableArray = NSMutableArray() variantList = abTest.variantList for variant in variantList { NSLog("Name is = %@ " , variant.name) } NSLog("Type is %@",abTest.type) } else { NSLog("%@", exception.reason!) NSLog("%d", exception.appErrorCode) NSLog("%d", exception.httpErrorCode) NSLog("%@", exception.userInfo!) } })Coming SoonComing SoonComing SoonComing SoonComing SoonComing SoonComing SoonComing SoonComing SoonComing SoonComing SoonComing Soon
The functions available under ABTest API can throw some exceptions in abnormal conditions. For example, if a developer is executing the testName which is not created or not in active mode, the function will throw the App42Exception (as shown below) with message as “Not Found” and the appErrorCode as “5800” and the details as “”.
String testName="<Enter the testName>"; App42API.initialize("ANDROID_APPLICATION_CONTEXT","API_KEY","SECRET_KEY"); ABTestService abTestService = App42API.buildABTestService(); abTestService.execute(testName, new App42CallBack() { public void onSuccess(Object response) { ABTest abTest = (ABTest)response; System.out.println("Test Name is : "+abTest.getName()); } public void onException(Exception ex) { App42Exception exception = (App42Exception)ex; int appErrorCode = exception.getAppErrorCode(); int httpErrorCode = exception.getHttpErrorCode(); if(appErrorCode == 5800) { // Handle here for Bad Request (Test either does not exist or it is not active.) } else if(appErrorCode == 1401){ // handle here for Client is not authorized } else if(appErrorCode == 1500){ // handle here for Internal Server Error } String jsonText = exception.getMessage(); } });String testName="<Enter the testName>"; App42API.Initialize("API_KEY","SECRET_KEY"); ABTestService abTestService = App42API.BuildABTestService(); abTestService.Execute(testName, new Callback()); public class Callback : App42Callback { public void OnException(App42Exception exception) { int appErrorCode = exception.GetAppErrorCode(); int httpErrorCode = exception.GetHttpErrorCode(); if(appErrorCode == 5800) { // Handle here for Bad Request (Test either does not exist or it is not active.) } else if(appErrorCode == 1401) { // handle here for Client is not authorized } else if(appErrorCode == 1500) { // handle here for Internal Server Error } String jsonText = exception.GetMessage(); } public void OnSuccess(Object response) { Console.WriteLine("Response Is : " + response); } }NSString *testName = @"<Enter the testName>"; [App42API initializeWithAPIKey:@"APP_KEY" andSecretKey:@"SECRET_KEY"]; ABTestService *abTestService = [App42API buildABTestService]; [abTestService execute:testName completionBlock:^(BOOL success, id responseObj, App42Exception *exception) { if (success) { ABTest *abTest = (ABTest*)responseObj; NSLog(@"Name =%@",abTest.name); NSLog(@"Type is %@",abTest.type); } else { int appErrorCode = exception.appErrorCode; int httpErrorCode = exception.httpErrorCode; if(appErrorCode == 5800) { // Handle here for Bad Request (Test either does not exist or it is not active.) } else if(appErrorCode == 1401) { // handle here for Client is not authorized } else if(appErrorCode == 1500) { // handle here for Internal Server Error } NSString *jsonText = exception.reason; } }];Coming SoonString testName="<Enter the testName>"; App42API.initialize("API_KEY","SECRET_KEY"); ABTestService abTestService = App42API.buildABTestService(); try { ABTest abTest=abTestService.execute(testName); } catch(App42Exception ex) { int appErrorCode = ex.getAppErrorCode(); int httpErrorCode = ex.getHttpErrorCode(); if(appErrorCode == 5800) { // Handle here for Bad Request (Test either does not exist or it is not active.) } else if(appErrorCode == 1401){ // handle here for Client is not authorized } else if(appErrorCode == 1500){ // handle here for Internal Server Error } String jsonText = ex.getMessage(); }String testName = "<Enter the testName>"; App42API.Initialize("API_KEY","SECRET_KEY"); ABTestService abTestService = App42API.BuildABTestService(); uploadService.Execute(testName, new UnityCallBack()); public class UnityCallBack : App42CallBack { public void OnException(Exception e) { App42Exception ex = (App42Exception)e; int appErrorCode = ex.GetAppErrorCode(); int httpErrorCode = ex.GetHttpErrorCode(); if(appErrorCode == 5800) { // Handle here for Not Found (Test either does not exist or it is not active.) } else if(appErrorCode == 1401){ // handle here for Client is not authorized } else if(appErrorCode == 1500){ // handle here for Internal Server Error } String jsonText = ex.GetMessage(); } public void OnSuccess(object response) { App42Log.Console("Response is " + response.ToString()); } }var testName="<Enter the testName>", appErrorCode ; App42.initialize("API_KEY","SECRET_KEY"); var abTestService = new App42ABTest(); abTestService.execute(testName,{ success: function(object) { }, error: function(error) { var userObj = JSON.parse(error); appErrorCode = userObj.app42Fault.appErrorCode; if(appErrorCode == 5800) { // Handle here for Not Found (Test either does not exist or it is not active.) } else if(appErrorCode == 1401){ // handle here for Client is not authorized } else if(appErrorCode == 1500){ // handle here for Internal Server Error } } });Coming SoonComing SoonString testName="<Enter the testName>"; App42API.Initialize("API_KEY","SECRET_KEY"); ABTestService abTestService = App42API.BuildABTestService(); try { ABTest abTest = abTestService.Execute(testName); } catch(App42Exception exception) { int appErrorCode = exception.GetAppErrorCode(); int httpErrorCode = exception.GetHttpErrorCode(); if(appErrorCode == 5800) { // Handle here for Not Found (Test either does not exist or it is not active.) } else if(appErrorCode == 1401){ // handle here for Client is not authorized } else if(appErrorCode == 1500){ // handle here for Internal Server Error } String jsonText = exception.GetMessage(); }$testName="<Enter the testName>"; App42API::initialize("API_KEY","SECRET_KEY"); $abTestService = App42API::buildABTestService(); try { $abTest = $abTestService.execute($testName); } catch(App42Exception $ex ) { $appErrorCode = $ex->getAppErrorCode(); $httpErrorCode = $ex->getHttpErrorCode(); if($appErrorCode == 5800) { // Handle here for Not Found (Test either does not exist or it is not active.) } else if($appErrorCode == 1401) { // handle here for Client is not authorized } else if($appErrorCode == 1500) { // handle here for Internal Server Error } String $jsonText = $ex->getMessage(); }Not AvailabeNot Availabevar testName:String="<Enter the testName>"; App42API.initialize("API_KEY","SECRET_KEY"); var abTestService:ABTestService = App42API.buildABTestService(); abTestService.execute(testName,new callback()); class callback implements App42CallBack { public function onException(exception:App42Exception):void { var appErrorCode:int = exception.getAppErrorCode(); var httpErrorCode:int = exception.getHttpErrorCode(); if(appErrorCode == 5800) { // Handle here for Bad Request (Test either does not exist or it is not active.) } else if(appErrorCode == 1401) { // handle here for Client is not authorized } else if(appErrorCode == 1500) { // handle here for Internal Server Error } } public function onSuccess(response:Object):void { var abtest:ABTest = ABTest(response); trace("resonse is: " + abtest) } }Not AvailabeString testName="<Enter the testName>"; App42API.initialize("API_KEY","SECRET_KEY"); ABTestService abTestService = App42API.buildABTestService(); try { ABTest abTest = abTestService.execute(testName); } catch(App42Exception exception) { int appErrorCode = exception.getAppErrorCode(); int httpErrorCode = exception.getHttpErrorCode(); if(appErrorCode == 5800) { // Handle here for Not Found (Test either does not exist or it is not active.) } else if(appErrorCode == 1401) { // handle here for Client is not authorized } else if(appErrorCode == 1500) { // handle here for Internal Server Error } String jsonText = exception.getMessage(); }
Functions in Gallery API might throw exceptions with following HTTP and Application Error Codes (along with their descriptions):
1400 - BAD REQUEST - The request parameters are invalid.
1401 - UNAUTHORIZED - Client is not authorized.
1500 - INTERNAL SERVER ERROR - Internal Server Error. Please try again.
5800 - NOT FOUND - Test either does not exist or it is not active.
5801 - NOT FOUND - Variant Not defined in given test.
5802 - BAD REQUEST - Variant Division Does Not Equal to 100.
5803 - BAD REQUEST - The request parameters are invalid. Goal Achieved is not applicable for Data-driven type.
Check that a given test is active or not and return the boolean value from the server.
Required Parameters
testName - Name of the test which is to check that it is active or not.
String testName="<Enter the testName>"; App42API.initialize("ANDROID_APPLICATION_CONTEXT","API_KEY","SECRET_KEY"); ABTestService abTestService = App42API.buildABTestService(); abTestService.isActive(testName, new App42CallBack() { public void onSuccess(Object response) { System.out.println(response); } public void onException(Exception ex) { System.out.println("Exception Message"+ex.getMessage()); } });String testName="<Enter the testName>"; App42API.Initialize("API_KEY","SECRET_KEY"); ABTestService abTestService = App42API.BuildABTestService(); abTestService.IsActive(testName, new Callback()); public class Callback : App42Callback { public void OnException(App42Exception exception) { Console.WriteLine("Exception Message" + exception.GetMessage()); } public void OnSuccess(Object response) { Console.WriteLine("Response Is : " + response); } }NSString *testName = @"<Enter the testName>"; [App42API initializeWithAPIKey:@"APP_KEY" andSecretKey:@"SECRET_KEY"]; ABTestService *abTestService = [App42API buildABTestService]; [abTestService isActive:testName completionBlock:^(BOOL success, id responseObj, App42Exception *exception) { if (success) { BOOL isActive = (BOOL*)responseObj; NSLog(@"isActive %d",isActive); } else { NSLog(@"Exception = %@",[exception reason]); NSLog(@"HTTP error Code = %d",[exception httpErrorCode]); NSLog(@"App Error Code = %d",[exception appErrorCode]); NSLog(@"User Info = %@",[exception userInfo]); } }];Coming SoonString testName="<Enter the testName>"; App42API.initialize("API_KEY","SECRET_KEY"); ABTestService abTestService = App42API.buildABTestService(); Boolean abTest= abTestService.isActive(testName); System.out.println(abTest);String testName="<Enter the testName>"; App42Log.SetDebug(true); //Prints output in your editor console App42API.Initialize("API_KEY","SECRET_KEY"); ABTestService abTestService = App42API.BuildABTestService(); abTestService.IsActive(testName, new UnityCallBack()); public class UnityCallBack : App42CallBack { public void OnSuccess(object response) { App42Log.Console("Response is : " + response); } public void OnException(Exception e) { App42Log.Console("Exception : " + e); } }var testName = "<Enter the testName>", abTestObj; App42.initialize("API_KEY","SECRET_KEY"); var abTestService = new App42ABTest(); abTestService.isActive(testName,{ success: function(object) { var result = JSON.parse(object); abTestObj = result.app42.response.abtest; console.log("IsActive is : " + abTestObj.isActive); }, error: function(error) { console.log("Exception is : " + error) } });Coming SoonComing SoonString testName="<Enter the testName>"; App42API.Initialize("API_KEY","SECRET_KEY"); ABTestService abTestService = App42API.BuildABTestService(); Boolean abTest= abTestService.IsActive(testName); Console.WriteLine("Response Is : " + abTest);$testName="<Enter the testName>"; App42API::initialize("API_KEY","SECRET_KEY"); $abTestService = App42API::buildABTestService(); $abTest = $abTestService->isActive($testName); print_r("Is Active is :".$abTest->isActive());Not AvailableNot Availablevar testName:String="<Enter the testName>"; App42API.initialize("API_KEY","SECRET_KEY"); var abTestService:ABTestService = App42API.buildABTestService(); abTestService.isActive(testName,new app42ABTestCallBack()); class callback implements App42CallBack { public function onException(exception:App42Exception):void { trace("Exception Message " + exception); } public function onSuccess(response:Object):void { if(response is ABTest) { var abtest:ABTest = ABTest(response); trace("Is Active : "+abtest.IsActive()); } } }Coming SoonString testName="<Enter the testName>"; App42API.initialize("API_KEY","SECRET_KEY"); ABTestService abTestService = App42API.buildABTestService(); Boolean abTest= abTestService.isActive(testName); System.out.println("Response is : " + abTest);