Support Home > SDK Integration > Unity SDK Integration

Unity SDK Integration

SDK

Unity Integration

Supported Platforms:

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

 

Minimum Requirements:

  • Unity version 4.7.2 (Highly recommended 5.2 or higher)
  • Android Target: API level 9 (Version 2.3)
  • iOS Target: 8.0

SDK Integration

The latest version of Kochava’s Unity SDK is provided for download at the bottom of this page.
Launch Unity and import the Kochava_Unity_xxxx.unitypackage file. Kochava can be integrated either through code or by adding the KochavaConfiguration prefab within the UI.

 

NOTE: For users of Unity version 4.7.2, the prefab drag and drop integration is not available. Follow the Code Integration instructions below.

 

Drag and Drop UI Integration:

  1. Drag and drop the Assets\Plugins\Kochava\KochavaConfiguration prefab into your scene. This scene should only be loaded once when your application launches.
  2. Select the newly added KochavaConfiguration object within the scene and enter each applicable Kochava App GUID in the appropriate platform-specific slot. The Unity Editor slot will be used as a default for any platforms not listed. You may also set any other initialization options here, such as a desired log level.
  3. If you will be building for Android or iOS please review their respective additional steps below.
  4.  

    A. Drag and Drop
    B. App specific data will be imported.

 

Code Integration (advanced):

Kochava can optionally be added through code by setting your Kochava App GUID and calling Initialize(). If you choose this route it is up to you to ensure that Kochava is initialized only once and that it’s scene survives changes. The Initialize() method will automatically create a game object named “KochavaTracker” and call DoNotDestroyOnLoad() on it. Please be aware that setting any Kochava.Tracker.Config values must be done before Kochava.Tracker.Initialize() is called.

 

Android Additional Integration Steps

Android Add Google Play Services –

  1. The Kochava SDK requires Google Play Services – Base and Google Play Services – Basement.
  2. Optionally – Kochava suggests you add Google Play Services – Location and it’s dependencies as well if you wish to collect location data. These files should all be added within the Assets > Plugins > Android folder. If collecting location you must also add the ACCESS_FINE_LOCATION and ACCESS_COARSE_LOCATION permissions to your android manifest. Below is a sample of how your file structure might look after adding these files.

     

     

    NOTE: In our testing, using Google Play Services v10.0.1 AARs, we found that Google Play Services – Location additionally required the Support v4 library (“support_compat”), which we added in the sample above. Your mileage may vary depending on which versions you use and how you integrate Google Play Services. For more information on adding Google Play Services, refer to Android support documentation.

 

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 –

Add this to your block to receive the install referrer from the Google Play Store:

View details »

iOS Additional Integration Steps

If using a Unity version lower than 5.0, be aware that there are other frameworks that this SDK requires. With the current version of Xcode, and with the default build settings, you generally do not need to add these frameworks manually to your Linked Frameworks and Libraries. But if you’ve disabled automatic linking, then you may also need to add the following frameworks:

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

View details »

 

Kochava is now integrated! Usage analytics will begin appearing in your Kochava.com dashboard. Read on to learn about sending post install events and a more detailed API reference guide.

 

BESTPRACTICES: The Kochava SDK does not require that you modify any code or files within the SDK. Modifying or moving any files within the SDK unity package will break the SDK or result in unexpected behavior.


Sending Post Install Events

Post install events can be instrumented using either standard or custom parameters to track the behavior of your users. No event pre-registration is required. Post install events can only be triggered after Kochava has initialized. If using the configuration object Kochava will be initialized during Awake() and you can begin to send events within Start().

 

Sending a Standard Event:

Standard events use common parameters and may be sent using the Kochava.SendEvent(Event) method. Choose an event type and any parameters you wish to create your event.

 

Sending a Custom Event:

Custom events provide you with full control over your event parameters and should only be used if your event parameters do not conform to the list of available standard parameters. Use the Kochava.SendEvent(eventName) or Kochava.SendEvent(eventName, eventData) methods to send a custom event. You may optionally send a stringified dictionary within the eventData parameter.

 

Sending In App Purchase Receipts:

Purchase receipts from Google Play and iOS app stores can be sent with your standard events by using the platform-specific setter within the Event object.

 

NOTE: Event names may not be prepended with an underscore, as that convention is reserved for Kochava system events. (i.e. _INSTALL)


API Reference

Configuration: Kochava App GUID:

Your Kochava App GUID(s) can be found in your dashboard at Kochava.com and should be different for each platform. If using the UI configuration you can simply enter each platform’s app guid into the appropriate platform-specific slot (the Unity Editor slot will be used by default). If using code it’s your responsibility to determine which app guid to use by platform.

UI Configuration –

Code Configuration –

 

Cofiguration: Log Level:

When enabled, the Kochava SDK will provide varying levels of diagnostic information within your target platform’s logging environment. Supported log levels include none, error, warn, info, debug and trace. Logging should always be set to none for production builds. For a list of logging output locations by platform please see: https://docs.unity3d.com/Manual/LogFiles.html

UI Configuration –

Code Configuration –

 

Configuration: Partner Name:

Reserved, may be provided by your account manager.

UI Configuration –

Code Configuration –

 

Configuration: App Ad Limit Tracking:

If you wish to limit ad tracking at the application level, with respect to Kochava conversions, you can turn off ad tracking (true) for the purpose of changing the limit ad tracking state, which will be off (false) by default (user opts-in to advertising). This can be set before or after initialization.

UI Configuration –

Code Configuration –

 

Configuration: Request Attribution Callback:

Attribution data can be received from Kochava server, usually in less than 10 seconds from the initial application launch. This is only required if you wish to do something with the attribution data from the server within your app; it is not required for attribution to work properly server-side. Unless you have a specific need within your app to read attribution data you do not need implement this feature.

UI Configuration –

Code Configuration –

 

Requesting attribution also requires that you provide a listener to receive the attribution data within code. This can be set anywhere within the first few seconds of launch.

 

Setting an Identity Link:

Identity Link events provide the opportunity to tie a Kochava device ID to your internal identifier. For example, you may have assigned each user of your app an internal userid which you want to connect to a user’s service identifier. Using the SetIdentityLink() method, you can send both your internal id with a device identifier and connect them in the Kochava database. Identity links should be set immediately after Kochava initialization when possible so that any identity link information will be sent with the install and be associated with any install postbacks.

 

Sending Deep Link:

Kochava offers this method for a convenient way to track your deep links. After receiving the uri, you can pass it along with your namespace to the deep link method. In iOS only, you may optionally pass the calling application.

 

Get your Kochava Device ID:

This method returns the Kochava Device ID.

 

Get your Attribution Data:

If you have chosen to retrieve attribution, this method will return the last-received attribution data string. Please note that attribution takes up to 10 seconds to be retrieved the first time. Calling this method before then will return an empty string.


Files for Download

NOTE: This is a substantial overhaul of the Unity SDK with API changes and adds new support for VR as well as MacOSX, Linux, Windows Desktop and WebGL (in addition to iOS and Android)

 

Kochava_Unity_3.0.0

 

NOTE: Depending on the browser/operating system, it may be required to right-click on the download link in order to download the Unity SDK.


Testing the Integration

For more information on testing the integration with Kochava, refer to our Testing an Integration with Kocahva support documentation.

 
 

Last Modified: Jul 19, 2017 at 12:02 pm