Attribution Integration Manual – Kochava

You can use this manual to start tracking app installations through Indus App Bazaar using Kochava Platform. Kochava is an attribution platform. Kochava Android SDK is a lightweight plugin which can be easily integrated into your Android project. The entire integration process takes less than five minutes and simply requires adding the SDK within your project and then starting the Kochava Tracker in code. .

To do integration and initialization of SDK, Please go to the following link :

https://support.freeappanalytics.com/sdk-integration/android-sdk-integration/

Set-up Attribution with Indus OS :

  • Marketer’s Task : Creating the tracking link for Indus OS on Kochava dashboard

    i) Go to Kochava dashboard -> Campaign Manager and Add a tracker

    ii) You can add your own ‘Tracker Name’ and add ‘IndusOS’ as ‘Media Partner’.
    iii) Click ‘Save’ to save the tracker details
     
     
     
     
    iv) Copy the ‘TRACKER GUID’ and ‘CLICK URL’
     
     
     
     

    Now, Click URL should look like this : https://control.kochava.com/v1/cpi/click?campaign_id=koattributiontest-elbkvrhe56b82f89d74d18&network_id=8831&ko_exchange=true&site_id=none-provided&device_id=device_id

    Note: Please ensure that ‘&device_id=device_id’ is present in the URL. If not present, please append it.

  •  v) Add Package name to Partner configuration

     Go to Partner Configuration -> IndusOS – Android and Select ‘Postbacks’

    Select ‘Install’ and choose ‘Edit’

    Add your ‘Package Name’ to Package name

    and click ‘Save’ .

    Please do the same process for ‘SessionBegin’ event. Edit the postback and add your package name.

 

 

  • Developer’s Task : Creating the custom apk with Kochava tracker embedded

Please insert the following code to the class in which you wish to start the tracker. Developer has to insert ‘GAID’ into the created tracking link and the app should hit it before starting the tracker. All the following changes need to be done in the same class. Also, it is assumed that all these changes are done in a subclass of context, otherwise the context needs to be passed appropriately.

i) Create a separate method named ‘initializeKochava()’ to configure Kochava tracker.

private void initializeKochava() {
    Tracker.configure(new Configuration(getApplicationContext())
            .setAppGuid(<YOUR_KOCHAVA_TRACKER_GUID>)
    );
    // Copy your Kochava Tracker GUID here.
    // For example, "koattributiontest-elbkvrhe56b82f89d74d18"
}

ii) Create an AsyncTask as a class variable which will hit the click URL and then start the tracker as in the sample code below. The click url created above will need to be used to replace the KOCHAVA_TRACK_URL in the sample code.

AsyncTask<Void, Void, String> task = new AsyncTask<Void, Void, String>() {
        @Override
        protected String doInBackground(Void... params) {
            String retVal = "false";
            AdvertisingIdClient.Info idInfo = null;
            String advertId = null;
            try {
                advertId = AdvertisingIdClient.getAdvertisingIdInfo(getApplicationContext()).getId();
            } catch (IOException| GooglePlayServicesNotAvailableException | GooglePlayServicesRepairableException e) {}

            String KOCHAVA_TRACK_URL = <KOCHAVA TRACK URL>;
            // Paste your Kochava tracker Click URL here
            // For example, "https://control.kochava.com/v1/cpi/click?campaign_id=koattributiontest-elbkvrhe56b82f89d74d18&network_id=8831&ko_exchange=true&site_id=none-provided&device_id=device_id"

            String track_url = KOCHAVA_TRACK_URL.replace("device_id=device_id","device_id=" + advertId) + "&pbr=1";
                
            HttpURLConnection urlConnection = null;
            try {
                URL url = new URL(track_url);
             
                urlConnection = (HttpURLConnection) url.openConnection();
                BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(urlConnection.getInputStream()));
                StringBuilder result = new StringBuilder();
                String line ;
                while ((line = bufferedReader.readLine()) != null) {
                    result.append('\n').append(line);
                }
                String response = result.toString();
                bufferedReader.close();

                if(response.contains("Success")){
                    retVal= "true";
                }

            } catch (Exception e) {
            }
            finally {
                urlConnection.disconnect();
            }
            return retVal;
        }

        @Override
        protected void onPostExecute(String response) {
            if("true".equalsIgnoreCase(response)){
                initializeKochava();
                SharedPreferences sharedPreferences = getSharedPreferences("kochava", 0);
                sharedPreferences.edit().putBoolean("kochavaTrackUrlHit", true).apply();
            }
        }
    };

iii) Replace the original Kochava tracker initialization code prior to any of these changes being started with the following. This will run the async task created above and then initialize kochava tracker and if the task has been already run once earlier then it will directly initialize kochava tracker without running any async task. .

if (!getSharedPreferences("kochava", 0).getBoolean("kochavaTrackUrlHit", false)) {
            task.execute();
        } else {
            initializeKochava();
        }

Once these code changes have been implemented, please build an APK and share the same APK with Indus OS team.