Support Home > SDK Integration > Unity – SDK Integration

Unity – SDK Integration


The Kochava Unity SDK is a lightweight plugin which can be easily integrated into your Unity 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. If you have already integrated the SDK and started the tracker, please visit Using the SDK and choose a topic.


Integrating the SDK

Requirements:

  • Unity version 5.0 or higher
  • Android API 14
  • Xcode 9.2

 

Supported Platforms:

  • Android
  • iOS
  • Linux
  • MacOS
  • WebGL
  • Windows Desktop
  • Windows Store (UWP)
  • VR Hardware:
    • Oculus Rift
    • HTC Vive
    • Samsung Gear VR
    • Google Daydream

Integration:

Estimated Time to Complete
5 Minutes

In order to use the Kochava SDK, first add it within your project. This can be accomplished by manually downloading the SDK and importing it or by using the Unity Asset Store to download it.

NOTE: When using the Kochava SDK from the Unity Asset Store you are required to also include and enable Unity Analytics. If you do not wish to enable Unity Analytics you may use the manually downloaded version of the Kochava SDK.

    1. Download the Kochava Attribution & Analytics asset in your project.
    2. Import the asset.

    1. Download the KochavaTrackerUnity.unitypackage file from the download badge above.
    2. Drag and drop the unitypackage into the Assets folder of your project.

Google Play Services:

The Kochava SDK requires the Google Play Services “play-services-ads-identifier” and its dependencies which at this time includes “play-services-basement”. These files should be added within the Assets > Plugins > Android folder.

 

Email Attribution:

If enabled in the Kochava dashboard for your app, the Kochava SDK can retrieve email addresses on the device, for use in attribution. If you wish to enable this capability, you need to add the GET_ACCOUNTS permission in your Android manifest.

 

Install Referrer:

In order to gather the Install Referrer the Kochava SDK requires the Google Play Install Referrer Library dependency. This file should be added within the Assets > Plugins > Android folder.

The Kochava SDK also gathers the legacy broadcast receiver based Install Referrer. In a typical project the broadcast receiver is automatically merged from the AAR package in the Kochava SDK into your manifest. If you are using an overridden manifest file then add this to your block to receive the legacy install referrer from the Google Play Store.


The SDK requires several additional frameworks as listed below. When using the default Xcode build settings you generally do not need to add these frameworks manually, but if you’ve disabled automatic linking, then you may also need to add the following to your Linked Frameworks and Libraries.

  • UIKit.framework
  • Foundation.framework
  • AdSupport.framework
  • iAd.framework
  • CoreLocation.framework
  • SystemConfiguration.framework
  • WebKit
  • AVFoundation


Unity version 2017 or higher is required for targeting the Windows Store (UWP) platform and also requires the following player settings:

  • API Compatibility Level: .NET 4.6
  • Permissions: Internet



Starting the Tracker

Estimated Time to Complete
1 Minute

Once you have added the Kochava SDK to your project, the next step is to configure and start the Kochava Tracker. Only your App GUID is required to start the tracker with the default settings, which is the case for typical integrations.

We recommend placing the Kochava Configuration Prefab in your launch scene, although this can be done elsewhere if needed. Starting the tracker as early as possible will provide more accurate session reporting and help to ensure the tracker has been started before using it. Keep in mind the tracker can only be configured and started once per launch.

The Kochava Configuration object will automatically start the Kochava SDK during the Awake lifecycle stage. Calls to the SDK should not be made until after this has occurred. The simplest way to ensure this is to not make any calls to the SDK until the Start lifecycle stage or later.

 

 

SDK WAYPOINT: At this point basic integration is complete and the Kochava SDK will begin reporting session activity and attributing installs.

 

Where to Go From Here:

Now that you have completed integration you are ready to utilize the many features offered by the Kochava SDK. Continue on to Using the SDK and choose a topic.


Custom Tracker Configuration

If you would like to make adjustments to the tracker configuration beyond the default settings, set your App GUID and the desired parameters and then pass it to the tracker’s configure method.

 

Using a Custom Configuration:


 

NOTE: Setting values within the KochavaConfiguration inspector view or the Kochava.Tracker.Config object will have no effect after the tracker has been started.

Below is a list of all configuration options and their default settings. Keep in mind that in a typical integration these configuration settings should not be adjusted from their default values.

Default — None

This string should be set to your Kochava App GUID, which can be found in your Edit App page within the Kochava dashboard. This value is always required (unless a Partner Name is set).

An individual Kochava App should be created for each published platform and its App GUID placed in its appropriate spot in the inspector. The Unity Editor App GUID will be used within the Editor and for any platform that a specific App GUID was not specified.

Default — None

Provide an attribution event listener if you wish to be notified of attribution results from Kochava servers. This is not necessary unless you wish to parse the attribution results for use within the app. When selecting a listener using the Unity Event Inspector UI ensure you select your method with the “Dynamic string” setting.

For complete details and examples, see: Retrieving Attribution.

Default — Info

Set this value to the desired Log Level to be used by the SDK for debugging purposes.

For complete details and examples, see: Enabling Logging.

Default — False

If you wish to limit ad tracking at the application level, with respect to Kochava conversions, set this value to true. It can also be toggled after starting the tracker.

For complete details and examples, see: App Limit Ad Tracking.

Default — None

This is a reserved setting and should not be set unless provided by your Client Success Manager.

Default — None

This is a reserved value and should not be set unless provided by your Client Success Manager.

Default — False

Set this value to true if you wish to start the tracker in Sleep mode. This advanced feature prevents the tracker from sending any network transactions and delays collection of the install data until woken.

For complete details and examples, see: Sleeping the Tracker.

Default — False

Android and iOS Only

As GDPR compliance can present many challenges during development, Kochava offers a fully managed solution for all your GDPR consent requirements through the use of our Intelligent Consent Management feature. By using this feature the Kochava SDK will handle determining when consent is required for any user while shouldering much the GDPR burden for you.

NOTE: This is an advanced feature requiring additional setup within your Kochava dashboard and should not be enabled without a full and complete understanding of how to use the Intelligent Consent Management feature.

For complete details and examples, see: Intelligent Consent Management.


Migration Guide

If you are migrating from a Kochava SDK version prior to version 4.0.0 then follow the migration steps outlined in the migration guide before proceeding with integrating the current SDK.

 
 

Last Modified: Nov 26, 2018 at 2:45 pm