The Kochava Windows SDK is a lightweight plugin which can be easily integrated into your Windows Store, Xbox One or Windows Desktop project. The entire integration process takes less than five minutes and simply requires adding the SDK reference within your project and then starting the Kochava Tracker in code.
Integrating the SDK
Requirements:
- Visual Studio 2015 or higher
Supported Platforms:
- Windows 10 and Xbox One (UWP Build 10240+)
- Windows 8.1 (WinRT)
- Windows Desktop (CLR .NET 4.5)
- HoloLens and Mixed Reality
Data Privacy:
Integration:

Estimated Time to Complete
5 Minutes
In order to use the Kochava SDK, first add it as a reference within your project. This can be accomplished using NuGet (recommended for Windows 10) or by downloading the SDK files manually and adding references to them.
NuGet Setup:
- Install the latest version of KochavaWRT via NuGet.
- KochavaWRT should now appear within your project’s references.
Manual Setup:
- Download and unzip the Kochava Windows SDK to a known location:
(Release Notes)
- Unzip and locate the folder for your desired build architecture and add the reference:
- In Visual Studio select Project > Add > Reference > Browse.
- Navigate to the unzipped Windows_Store folder and add the Kochava.winmd file.
- KochavaWRT should now appear within your project’s references.
Once you have added the Kochava SDK reference, you are ready to proceed to Starting the Tracker below. All sample code assumes you have added the appropriate #using statement for the KochavaWRT namespace wherever Kochava related code is implemented.
#using KochavaWRT;

Estimated Time to Complete
10 Minutes
The Kochava SDK APIs can be used from within a WebView for scenarios where you have a native app with an embedded WebView. The examples provided in this topic shows the most common usage but additional APIs can be added by following the same pattern.
Calling the SDK from within your WebView requires the following steps.
- Include the JavaScript snippet within your WebView
- Add a handler that intercepts the API calls in your native code
- Call the JavaScript APIs in your WebView
1. Include the JavaScript Snippet
Place the following JavaScript snippet within your website. This must be available in a way where it can be called from your own JavaScript.
Example (JavaScript Snippet)
function registerIdentityLink(name, value) {
postUrl('kochavameasurement://registerIdentityLink?name='+encodeURIComponent(name)+'&value='+encodeURIComponent(value));
}
function sendEvent(eventName, eventData) {
postUrl('kochavameasurement://sendEvent?eventName='+encodeURIComponent(eventName)+'&eventData='+encodeURIComponent(JSON.stringify(eventData)));
}
function postUrl(url) {
var i = document.createElement('iframe');
i.style.display = 'none';
i.onload = function() { i.parentNode.removeChild(i); };
i.src = url;
document.body.appendChild(i);
}
2. Add Native Handler
Add the native code which interacts with the WebView. This code will handle the API calls from the JavaScript snippet in the WebView and route them to the appropriate native API.
Example (Native Handler)
// NOTE: This is an example code sample, the actual code sample will be provided by the specific SDK documentation.
public final class SampleUtilizationFromAWebView extends WebViewClient {
/**
* Override the URL handler and see if we are consuming the url load.
*/
@Override
public boolean shouldOverrideUrlLoading(@NonNull final WebView webView, @NonNull final String urlString) {
if (kochavaMeasurementUrlHandler(urlString)) {
return true;
}
// Handle others as needed
// ...
return false;
}
/**
* Checks if the given url is a Kochava command and performs its action as required.
* <p>
* @return true if it is Kochava Measurement Command and false for all others.
*/
private boolean kochavaMeasurementUrlHandler(@NonNull final String urlString) {
final String kochavaPrefix = "kochavameasurement://";
if(!urlString.startsWith(kochavaPrefix)) {
// Not a Kochava Measurement Command
return false;
}
// Handle all Kochava Measurement Commands
if(urlString.startsWith(kochavaPrefix + "registerIdentityLink")) {
final Uri url = Uri.parse(urlString);
final String name = url.getQueryParameter("name");
final String value = url.getQueryParameter("value");
Measurement.getInstance().registerIdentityLink(name != null ? name : "", value);
} else if (urlString.startsWith(kochavaPrefix + "sendEvent")) {
final Uri url = Uri.parse(urlString);
final String eventName = url.getQueryParameter("eventName");
final String eventData = url.getQueryParameter("eventData");
JSONObject eventDataParsed;
try {
eventDataParsed = new JSONObject(eventData);
} catch (JSONException e) {
eventDataParsed = new JSONObject();
// Handle exception as needed
}
Event.buildWithEventName(eventName != null ? eventName : "")
.mergeCustomDictionary(eventDataParsed)
.send();
} else {
// Unrecognized Kochava Measurement Command
}
// Processed Kochava Measurement Command
return true;
}
}
3. Call the JavaScript APIs
From your code in the WebView you can now call the SDK’s JavaScript API as defined in the snippet included above.
Example (Basic Usage)
<button style="width: 100%; font-size: 16pt" onclick='
registerIdentityLink("user_id", "abcdefg");
'>Register Identity Link</button>
<p/>
<button style="width: 100%; font-size: 16pt" onclick='
var eventData = {};
eventData["user_id"] = "abcdefg";
eventData["user_name"] = "user_123";
sendEvent("Registration Complete", eventData);
'>Send Event</button>
Our Classic Windows Desktop plugin is a lightweight .NET CLR library written in C#, which can be integrated into Windows Desktop applications supporting .NET 4.5.
Typical .NET App Integration:
- Download and unzip the Kochava Windows SDK to a known location:
(Release Notes)
- Add the references:
- In Visual Studio 2015/2017 Select Project > Add Reference > Browse.
- In Visual Studio 2013 Select Project > References > Add New Reference > Browse.
- Navigate to the unzipped Windows_Desktop_NET45 folder and add both the Kochava.dll and JsonFX.Json.dll files.
- KochavaNET should appear under your project’s references and you are ready to proceed to Starting the Tracker section below.
Unmanaged C++ Apps:
A requirement for the the Kochava SDK is support for CLR and .NET 4.5. Your app must be able to support this in order to use the SDK. For an unmanaged C++ app, it is possible to enable this support from within your project settings:
- In Project > Properties > General enable Common Language Runtime Support (/clr).
- In Project > Properties > General > .NET Target Framework Version Enter 4.5
- At this point your app supports CLR and targets the .NET 4.5 framework and you can follow the steps above for a .NET app integration. However, depending on your internal requirements you may or may not be able to support this. If you cannot, a client-built SDK or Server to Server integration would need to be used.
Once you have added the Kochava SDK reference, you are ready to proceed to Starting the Tracker. All sample code assumes you have added the appropriate #using statement for the KochavaNET namespace wherever Kochava related code is implemented.
#using KochavaNET;

Estimated Time to Complete
10 Minutes
The Kochava SDK APIs can be used from within a WebView for scenarios where you have a native app with an embedded WebView. The examples provided in this topic shows the most common usage but additional APIs can be added by following the same pattern.
Calling the SDK from within your WebView requires the following steps.
- Include the JavaScript snippet within your WebView
- Add a handler that intercepts the API calls in your native code
- Call the JavaScript APIs in your WebView
1. Include the JavaScript Snippet
Place the following JavaScript snippet within your website. This must be available in a way where it can be called from your own JavaScript.
Example (JavaScript Snippet)
function registerIdentityLink(name, value) {
postUrl('kochavameasurement://registerIdentityLink?name='+encodeURIComponent(name)+'&value='+encodeURIComponent(value));
}
function sendEvent(eventName, eventData) {
postUrl('kochavameasurement://sendEvent?eventName='+encodeURIComponent(eventName)+'&eventData='+encodeURIComponent(JSON.stringify(eventData)));
}
function postUrl(url) {
var i = document.createElement('iframe');
i.style.display = 'none';
i.onload = function() { i.parentNode.removeChild(i); };
i.src = url;
document.body.appendChild(i);
}
2. Add Native Handler
Add the native code which interacts with the WebView. This code will handle the API calls from the JavaScript snippet in the WebView and route them to the appropriate native API.
Example (Native Handler)
// NOTE: This is an example code sample, the actual code sample will be provided by the specific SDK documentation.
public final class SampleUtilizationFromAWebView extends WebViewClient {
/**
* Override the URL handler and see if we are consuming the url load.
*/
@Override
public boolean shouldOverrideUrlLoading(@NonNull final WebView webView, @NonNull final String urlString) {
if (kochavaMeasurementUrlHandler(urlString)) {
return true;
}
// Handle others as needed
// ...
return false;
}
/**
* Checks if the given url is a Kochava command and performs its action as required.
* <p>
* @return true if it is Kochava Measurement Command and false for all others.
*/
private boolean kochavaMeasurementUrlHandler(@NonNull final String urlString) {
final String kochavaPrefix = "kochavameasurement://";
if(!urlString.startsWith(kochavaPrefix)) {
// Not a Kochava Measurement Command
return false;
}
// Handle all Kochava Measurement Commands
if(urlString.startsWith(kochavaPrefix + "registerIdentityLink")) {
final Uri url = Uri.parse(urlString);
final String name = url.getQueryParameter("name");
final String value = url.getQueryParameter("value");
Measurement.getInstance().registerIdentityLink(name != null ? name : "", value);
} else if (urlString.startsWith(kochavaPrefix + "sendEvent")) {
final Uri url = Uri.parse(urlString);
final String eventName = url.getQueryParameter("eventName");
final String eventData = url.getQueryParameter("eventData");
JSONObject eventDataParsed;
try {
eventDataParsed = new JSONObject(eventData);
} catch (JSONException e) {
eventDataParsed = new JSONObject();
// Handle exception as needed
}
Event.buildWithEventName(eventName != null ? eventName : "")
.mergeCustomDictionary(eventDataParsed)
.send();
} else {
// Unrecognized Kochava Measurement Command
}
// Processed Kochava Measurement Command
return true;
}
}
3. Call the JavaScript APIs
From your code in the WebView you can now call the SDK’s JavaScript API as defined in the snippet included above.
Example (Basic Usage)
<button style="width: 100%; font-size: 16pt" onclick='
registerIdentityLink("user_id", "abcdefg");
'>Register Identity Link</button>
<p/>
<button style="width: 100%; font-size: 16pt" onclick='
var eventData = {};
eventData["user_id"] = "abcdefg";
eventData["user_name"] = "user_123";
sendEvent("Registration Complete", eventData);
'>Send Event</button>
If your app is targeting Windows 8.1/Windows Phone 8.1 platforms or otherwise requires a C++ WinRT build of the SDK, please use the legacy Kochava SDK version 3.0.1, which is a WinRT Component written in C++ supporting Windows 8.1 WinRT and Windows 10 UWP.
Manual Setup:
- Download the legacy SDK:
(Release Notes)
- Unzip and locate the folder for your desired build architecture and add the reference:
- In Visual Studio 2015/2017 Select Project > Add Reference > Browse.
- In Visual Studio 2013 Select Project > References > Add New Reference > Browse.
- Add the unzipped Kochava.winmd file as a reference to your project.
- The Kochava SDK should now appear within your project’s references.
Once you have added the Kochava SDK reference, you are ready to proceed to Starting the Tracker section. All sample code assumes you have added the appropriate #using statement for the Kochava namespace wherever Kochava related code is implemented.
#using Kochava;
Starting the Tracker

Estimated Time to Complete
1 Minute
Once you have added the Kochava SDK reference to your project, the next step is to configure and start the Kochava Tracker in code. Only your App GUID is required to start the tracker with the default settings, which is the case for typical integrations.
We recommend starting the tracker within the constructor of your App singleton, 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.
Start the Shared Instance with Default Settings (recommended):
public App()
{
this.InitializeComponent();
this.Suspending += OnSuspending;
// start the Kochava Tracker
SharedInstance.Initialize("_YOUR_APP_GUID_");
}
We also recommend that you use the Shared Instance of the tracker, rather than creating your own tracker instance. By doing so you will not need to create or keep track of the instance yourself. In this documentation we will always use the Shared Instance of the tracker and reference it by SharedInstance.Tracker. If you create your own instance you will simply reference it directly in place of SharedInstance.Tracker.
Create Your Own Instance of the Tracker:
// start your own instance of the Kochava Tracker
var myTracker = new Tracker("_YOUR_APP_GUID_", LogLevel.none);
Confirm the Integration
After integrating the SDK and adding the code to start the measurement client, launch and run the app for at least 10 seconds or more. During this time the client will start and send an install payload to Kochava. To confirm integration was successful, visit the app’s Install Feed Validation page Apps & Assets > Install Feed Validation. On this page you should see one of two integration messages, indicating integration success or failure.
Integration Successful
Along with this message you will also see a variety of data points associated with the device used for testing. At this point your integration is successful and you can proceed to the next step(s).
Integration Not Complete
If you encounter this message, please review the integration steps, uninstall and reinstall the app, and check again.
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, use a Config object to start the tracker. To accomplish this, create the config object, set your App GUID and the desired parameters, and then pass it to the tracker’s initialization method.
Starting the Shared Instance Using a Custom Configuration:
public App()
{
this.InitializeComponent();
this.Suspending += OnSuspending;
// initialize the Kochava Tracker
var config = new Config();
config.AppGUID = "_YOUR_APP_GUID_";
config.LogLevel = LogLevel.none;
SharedInstance.Initialize(config);
}
Creating Your Own Instance Using a Custom Configuration:
var config = new Config();
config.AppGUID = "_YOUR_APP_GUID_";
config.LogLevel = LogLevel.none;
var myTracker = new Tracker(config);
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.
Setting the AppGUID:
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).
config.AppGUID = "_YOUR_APP_GUID_";
Retrieving Attribution:
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.
For complete details and examples, see: Retrieving Attribution
Setting Identity Links:
Default — None
Call this method for each identity link key/value pair which is known before starting the tracker. Identity Links can also be set after starting the tracker using the Tracker.SetIdentityLink method.
For complete details and examples, see: Identity Linking
Setting a Log Level:
Default — LogLevel.info
Set this value to the desired Log Level to be used by the SDK for debugging purposes. You will also need to subscribe to the Tracker.LoggingEvent before starting the tracker to output the messages to a console or elsewhere.
For complete details and examples, see: Enabling Logging
Setting App Limit Ad Tracking:
Default — false
If you wish to limit ad tracking at the application level, with respect to Kochava conversions, set this value to false. It can also be toggled after starting the tracker using the Tracker.SetAppLimitAdTracking setter.
For complete details and examples, see: App Limit Ad Tracking
Setting a Custom Value:
Default — (none)
This is a reserved setting and should not be set unless provided by your Client Success Manager.
Setting a Partner Name:
Default — (none)
This is a reserved value and should not be set unless provided by your Client Success Manager.
Setting a Sleep State:
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
Setting a Custom User Agent:
Default — (none)
Primarily for purposes of adjusting modeled attribution results, set this string to the desired non-encoded user agent to be used in place of the default user agent which is normally generated by the SDK using a XAML WebView. This may be useful when XAML is otherwise unavailable, such as within a pure DirectX game.
config.CustomUserAgent = "Mozilla/5.0 (Windows NT 6.3; Trident/7.0; rv:11.0) like Gecko";
Setting the Development Build Flag:
Default — (false)
Certain data collection such as the campaign id or install receipt can cause sluggish behavior in a development environment, as these items are not available for collection in a sideloaded build and usually require time consuming loading of extra symbols. By setting this flag to true the collection of data like this will be skipped. However, care should be taken that this flag is never set to true for a release build.
#if DEBUG
config.DevelopmentBuild = true;
#endif
Enabling Intelligent Consent Management:
Default — (false)
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.
config.IntelligentConsentManagement = true;
For complete details and examples, see: Intelligent Consent Management