Support Home > SDK Integration > Xamarin Plugin

Xamarin Plugin

xamarinpluginlogohd

 

DOCUMENT SUPERSEDED: The information that is contained within this document has been superseded. Refer to the current SDK integration support document for the latest integration instructions and procedures.

 


Our full SDK integrates quickly and easily into a Xamarin iOS, Android or Windows app. The Kochava SDK allows advertisers to integrate a single SDK to leverage the hundreds of ad networks and publisher partners via Kochava. This limits the number of third-party SDKs required to run a successful user acquisition strategy and greatly reduces complexity during update cycles. Find documentation for other SDKs, plugins, and Server-to-Server Integrations.

 

Minimum Requirements:

  • Android: API Level 9
  • iOS: Version 8.0
  • Windows 8.1

Integration Instructions

NOTE: For a more streamlined integration, add the Kochava component within Xamarin.

 

Follow the steps below to get the Kochava SDK integrated into a Xamarin app.

 

NOTE: For Windows apps, refer to our Windows SDK Integration support documentation.

 

Add the Kochava SDK:

  1. Download the Kochava SDK package zip.
  2. Unzip and extract the DLL file into a known location.
  3. Add a reference to the DLL in the app’s project:
  4. Visual Studio –

    a. Right-click the References folder in your project and click Add Reference.
    b. Click Browse and locate the DLL file.

    Xamarin Studio –

    a. From the project’s Native References folder add the DLL file (under .NET Assemblies).

 

Android: Add Google Play Services:

 

NOTE: The following instructions are for Android only, customers interested in integrating with iOS apps proceed to Add the Code section.

 

  1. Our Android SDK plugin requires references to Xamarin.GooglePlayServices.Analytics and Xamarin.GooglePlayServices.Location (only if gathering location). If your Android app already includes these references, there is nothing more you need to do. Otherwise, add these Xamarin components to your app:
  2.  

    Analytics: https://components.xamarin.com/view/googleplayservices-analytics
    Location: https://components.xamarin.com/view/googleplayservices-location

     

  3. Under required permissions Check INTERNET, ACCESS_WIFI_STATE and ACCESS_NETWORK_STATE.
  4. To gather location, Check ACCESS_COARSE_LOCATION and ACCESS_FINE_LOCATION.

 

Add the Code:

Now that the references are added the code can be added. Below is a sample of how the code might look after integration and shows how to integrate Kochava into a new single view app.

 

BEST PRACTICES: Before initializing the SDK make sure you’ve obtained your unique App GUID, as you will need to pass it to the initializer. For more information on locating your App GUID, refer to our Locating an App GUID support documentation.

 

Once you’ve obtained your App GUID it can be passed as the Kochava App ID value during initialization. In the sample code below simply replace “_YOUR_APP_GUID_” with your App GUID.

 






Sending Events

Sending Kochava post-install events is not a requirement. To track installation information, you need only call the initializer. Many advertisers want to understand and correlate the relationship between conversion and attribution source information with post-install behaviors. This can only be done by tracking post-install events.

Once the initializer is called, the Kochava event tracking method can be called from anywhere within the application. Events will be coupled with the information sent by the initializer to report events, based on user device and application information.

Events are stored in memory and sent individually or in bulk depending on the volume of events collected and instrumented. This is done to separate event collection from event transmission and removes any impact it could make on your application.

Events are not sent immediately to Kochava servers but are queued should the device lose connectivity.
 

Sending a Standard Event:

To send a standard event, simply create a new KochavaEvent object with a chosen KochavaEventType and populate only the fields you would like to include with the event, if any. Next, call the SendEvent() method with the KochavaEvent object to send the event.

 

Sample Code:

 

Sending a Custom Event:

No event pre-registration is required. To send a custom event, simply send an event name via the eventName parameter. Optionally, you can also send an eventValue. The optional eventValue parameter is used to gather in-app purchase information that can be used for LTV calculation.
Regardless of what is passed in eventValue, the Kochava user dashboard will let you access all the data passed in as data for any event and present a count of all the times any given event was sent. Note that if you pass a string of JSON represented data, only the root level (no nested chunks) is stored. Also, any given value in a JSON key/value pair will be truncated after 75 characters.

 

Sample Code:

 

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

NOTE: For examples of post-install events refer to our Post-Install Event Examples support documentation.

 

Sending an Event with Receipt Data:

Similar to the event methods, specially formatted data from an App Store or Google Play Store receipt may be sent to Kochava servers.

 

NOTE: At this time, an event with receipt data is a beta feature in the Xamarin plug-in. Please contact us for assistance if you wish to implement this type of event.


Attribution Data Request

Attribution data can be retrieved via a callback if you choose. To accomplish this, simply inform the SDK you would like to receive attribution during initialization and create a handler to receive the attribution data.

 

NOTE: This should only be done if your application makes use of this information, otherwise it causes needless network communication. Attribution will performed server-side regardless of the application requesting the results.

 

Initialization Code Sample:





 

For a complete code sample including this attribution handler setup please scroll up to the top of the page.

Toggle Limit-Ad-Tracking

If you wish to toggle the collection of the advertiser ID you can use this method to turn it on or off.

 






Send IdentityLink

IdentityLink events provide the opportunity to “link different identities” together. For example, you may have assigned each user of your app an internal user ID which you want to connect to a user’s service identifier. Using the IdentityLink method, you can send both your internal ID and their service identifier connecting them in the Kochava database.

Kochava reports can be created to show additional identity information for devices in the Kochava database so that you can supplement your reports with internal identifiers that are useful to you and your application.

Although you can call the IdentityLink method any time, it is best called once per data pair being connected, and it is your responsibility to know you have or have not made that connection.
 
NOTE: IdentityLink values must be strings.
 


Deep Linking

Pass deep link events to Kochava using this method. After retrieving the URI, just pass it as a parameter and Kochava will register that event specifically as a deep link.
 


Get Device ID

You may want to retrieve the Kochava Device ID from the SDK for your own use.
 


Get Attribution Data

Attribution data has been retrieved from the server at any time.
 


Logging

If enabled, the Kochava SDK provides error messages to assist in debugging problems you might be having with integrating the SDK into your app. If you would like to turn these on, you can add the following key/value pair to the Kochava initialization dictionary:

 


  •  

    NOTE: For production releases, logging should not be used.

     

    Available Logging Levels:

    Feature.LogLevel.none
    Feature.LogLevel.error
    Feature.LogLevel.warn
    Feature.LogLevel.info
    Feature.LogLevel.debug
    Feature.LogLevel.trace

  •  

    NOTE: For production releases, logging should not be used.

     

    Available Logging Levels:

    KochavaTracker.Constants.kKVALogLevelEnumNone
    KochavaTracker.Constants.kKVALogLevelEnumError
    KochavaTracker.Constants.kKVALogLevelEnumWarn
    KochavaTracker.Constants.kKVALogLevelEnumInfo
    KochavaTracker.Constants.kKVALogLevelEnumDebug
    KochavaTracker.Constants.kKVALogLevelEnumTrace


Files for Download

NOTE: For a more streamlined integration, add the Kochava component within Xamarin.

 


  • [ithoughts_tooltip_glossary-tooltip href=”https://storage.googleapis.com/support-kochava/2017/01/Xamarin-Android-SDK-Release-Notes_1.1.0.pdf” target=”_blank” tooltip-content=”
    <h6><strong>SDK Version – 1.1.0</strong></h6><br/><ul><br/><li><br/><h6>Improved handling of thread concurrency.</h6><br/></li><br/></ul><br/><ul><br/><li><br/><h6>Improved memory and cpu usage when sending large volumes of post install events.</h6><br/></li><br/></ul><br/><ul><br/><li><br/><h6>Added additional data points to post install and event payloads.</h6><br/></li><br/></ul><br/><h6><strong>SDK Version – 20160914</strong></h6><br/><ul><br/><li><br/><h6>Initial Release</h6><br/></li><br/></ul><br/>”]Kochava Xamarin-Android Release Notes[/ithoughts_tooltip_glossary-tooltip]
    KochavaTracker_Android_Xamarin_1.1.0.zip

  • [ithoughts_tooltip_glossary-tooltip href=”https://storage.googleapis.com/support-kochava/2017/01/Xamarin-iOS-SDK-Release-Notes_1.1.0.pdf” target=”_blank” tooltip-content=”
    <h6><strong>SDK Version – 1.1.0</strong></h6><br/><ul><br/><li><br/><h6>Performance and stability improvements.</h6><br/></li><br/></ul><br/><h6><strong>SDK Version – 20160914</strong></h6><br/><ul><br/><li><br/><h6>Initial Release</h6><br/></li><br/></ul><br/>”]Kochava Xamarin-iOS Release Notes[/ithoughts_tooltip_glossary-tooltip]
    KochavaTracker_iOS_Xamarin_1.1.0.zip
  • For Windows download, refer to our Windows SDK Integration support documentation.


Testing the Integration

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

 
 

Last Modified: Sep 5, 2017 at 9:52 am