Skip to content

Recommendations

Casey Kulm edited this page Apr 4, 2016 · 59 revisions

Summary

Product Recommendations is currently in BETA! If you would like to participate in the Beta Pilot Program, please contact Mobile Development at Bazaarvoice

This page describes how you configure the Recommendations in your Android Studio project so you can begin to use the funcionality of the Recommendations SDK module.

NOTE: Make sure you have your Shopper Advertising API Key and Client ID before initializing the BVSDK!

Configure the Recommendations Module:

App Gradle - Add dependencies

Include Maven Central repository and add Common and Advertising modules to dependencies

dependencies {
    compile 'com.bazaarvoice.bvandroidsdk:recommendations:3.2.0'
}
repositories {
    mavenCentral()
}

###Java - Extend Application Create a class that extends android.app.Application and initialize the SDK using its builder. Full list of build options are found in BVSDK.java

public class BVApplication extends Application {

    @Override
    public void onCreate(){
        super.onCreate();

        // Builder used to initialize the Bazaarvoice SDKs
        BVSDK bvsdk = new BVSDK.Builder(this, YOUR_CLIENT_ID)
                .bazaarEnvironment(BazaarEnvironment.PRODUCTION) //Either staging or production. Use corresponding API keys
                .apiKeyShopperAdvertising(YOUR_SHOPPER_ADVERTISING_API_KEY) //Required for Recommendations
                .logLevel(BVLogLevel.INFO)
                .build();
    }
}

###AndroidManifest - set the name of the class for the application entry and request internet permission

    <uses-permission android:name="android.permission.INTERNET" />

    <application
        android:name=".BVApplication">
    </application>

Use the Recommendations API

Set User Information

Once a Recommendations instance has been created, you can also set an authenticated user for profile matching. Please refer to User Authentication for steps on how to accomplish this.

This step is not required, however the end-user may receive trending product recommendations over personalized recommendations.

To set authenticated user call setUserWithAuthString on you Recommendations instance

BVSDK.getInstance().setUserAuthString("USER_AUTH_STRING);

Get Recommendations

At this point you should be able to fetch a shopper profile with product recommendations.

Recommendations recs = new BVRecommendations();

recs.getRecommendedProducts(20, new Recommendations.BVRecommendationsCallback() {
    @Override
    public void onSuccess(List<BVProduct> recommendedProducts) {

    }

    @Override
    public void onFailure(Throwable throwable) {

    }
});

Refer to Recommendations.java interface for getting recommendations based on a categoryId or productId. Refer to RecommendationsFragment in the app module for a demo implementation.