Assets A/B Test
With Vessel you can publish A/B test rich media assets including images, videos, promotional ads, etc.
1. Create Test and Upload Assets
- Create a "Fruit Assets Test"
- Create a asset key e.g. fruit_image and upload assets as shown below.
2. Get Assets
Using Vessel assets API you can get assets directly without worrying about caching or hosting. Vessel SDK ensures that the correct content is delivered to the right device.
/**
Get the image associated with a given test variation variable. If there is none associated or the test failed to load then the will execute failure block.
*/
[VesselAB fromTest:@"Fruit Assets Test" getImageFor:@"ads_assets" success:^(UIImage *variationImage) {
// Get Image and show apple vs orange
} failureBlock:^{
// Show your default image
}];
/**
* This method downloads and caches the image asset associated with given key
* @param testName :Name of the test, in which you have uploaded image assets.
* @param key : Variation key to loop up the image.
* @param listener: This is asynchronous method, you need to set a call back, return image container on success.
* @return
*/
VesselAB.getImageForKey("Fruit Assets Test", "fruit_image", new
VesselImageListener() {
@Override
public void onErrorResponse(VolleyError error) {}
@Override
public void onResponse(ImageContainer response, boolean isImmediate) {
..
Bitmap fruitImage = response.getBitmap();
...
//Show image
}
});
3. Get Assets Url
If you prefer to download and handle asset caching then you can also query for request url by using following method.
/** Returns the assetUrl associated with a given test asset variation variable. If there is none associated or the test failed to load then the defaultValue is returned.
@param testName The test name from which variation variable needs to be retrieved.
@param variableKey The variableKey whose value is to the retrieved.
@param defaultValue In case there is no variation variable named variationVariable or if the test failed to load then the defaultValue is returned.
*/
NSString *variationAssetUrl = [VesselAB fromTest:@"asset_demo" getAssetUrl:@"ads_assets" defaultValue:@"YOUR_DEFAULT_URL"];
/**
* Get the asset URL for given asset key in a test, if test is active.
*
* @param testName
* - Name of the test
* @param key
* - Asset key as defined on the site
* @return URL of the asset, if test is active and URL is available. Or else returns null
*/
VesselAB.getAssetUrlForKey("Fruit Assets Test", "fruit_image");
/**
* Get the asset URL for given asset key in a test, if test is active.
*
* @param testName
* - Name of the test
* @param key
* - Asset key as defined on the site
* @return URL string of the asset, if test is active and URL is available. Or else returns ""
*/
vesselsdk.getAssetURL("Fruit Assets Test", "fruit_image");
Updated less than a minute ago