Skip to content
Sanu gupta edited this page Oct 11, 2022 · 9 revisions

unity-sdk

Table of Content

Integration

Quick start guide

We have created a example app for the Unity SDK integration.

Please check the Example directory for know to how the Trackier SDK can be integrated.

Add Unity SDK to your app

Unity SDK is very easy to integrate in your app. Just need to follow some steps

To integrate the Trackier SDK into your Unity project, follow these steps.

Get the SDK As of version 1.0.1 you can download the latest version from our releases page.

Add the SDK to your project Open your project in the Unity Editor, go to Assets → Import Package → Custom Package and select the downloaded Unity package file.

Screenshot 2022-06-10 at 3 46 48 PM

Integrate and Initialize the Trackier SDK

Retrieve your dev key

For initialising the Trackier SDk. First, We need to generate the Sdk key from the Trackier MMP panel.

Following below are the steps to retrieve the development key:-

  • Login your Trackier Panel
  • Select your application and click on Action button and login as
  • In the Dashboard, Click on the SDK Integration option on the left side of panel.
  • under on the SDK Integration, You will be get the SDK Key.

After follow all steps, Your SDK key look like the below screenshot

Screenshot[1]

Screenshot 2022-06-10 at 3 46 48 PM

Integrate the Trackier SDK in the Unity Application.

Integrate the SDK into your app

Initialize Trackier SDK :- After importing package successfully, you would be seeing a Trackier named folder in which you will find Trackier.cs file.

In the following line add your app_token.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using com.trackier.sdk;

namespace com.sampleapp
{
    public class Script : MonoBehaviour
    {
        // Start is called before the first frame update
        void Start()
        {
            /*While Initializing the Sdk, You need to pass the two arguments in the TrackierSDKConfig.
            you need to pass the Trackier SDK api key in the argument */

            /* Initialize sdk */
            TrackierUnity.start("xxxx-xx-4505-bc8b-xx");
        }

        // Update is called once per frame
        void Update()
        {

        }
    }
}

Screenshot[2]

Screenshot 2022-07-28 at 9 33 39 AM

Events Tracking

Trackier events trackings enable to provides the insights into how to user interacts with your app. Trackier sdk easily get that insights data from the app. Just follow with the simple events integration process

Trackier provides the Built-in events and Customs events on the Trackier panel.

Built-in Events -

Predefined events are the list of constants events which already been created on the dashboard.

You can use directly to track those events. Just need to implements events in the app projects.

Screenshot[3]

Screenshot 2022-06-10 at 1 23 01 PM

Example code for calling Built-in events

  /*
 * Event Tracking
  <------------->
 * The below code is the example to pass a event to the Trackier SDK.
 * This event requires only 1 Parameter which is the Event ID.
 * Below are the example of built-in events function calling
 * The arguments - "TrackierEvent.LOGIN" passed in the Trackier event class is Events id
 *
 */

 public class Script : MonoBehaviour
    {
        // Start is called before the first frame update
        void Start()
        {
            /*While Initializing the Sdk, You need to pass the two arguments in the TrackierSDKConfig.
            you need to pass the Trackier SDK api key in the argument */

            /* Initialize sdk */
            TrackierUnity.start("xxxx-xx-4505-bc8b-xx");

            /* Event Track */
             /*
            * Event Tracking
            <------------->
            * The below code is the example to pass a event to the Trackier SDK.
            * This event requires only 1 Parameter which is the Event ID.
            * Below are the example of built-in events function calling
            * The arguments - "sEMWSCTXeu" passed in the Trackier event class is Events id
            */
            TrackierEvent trackierEvent = new TrackierEvent("sEMWSCTXeu"); //pass your eventid here
            trackierEvent.param1 = "param";
            TrackierUnity.trackierEvent(trackierEvent);
        }

        // Update is called once per frame
        void Update()
        {

        }
    }

Note:- Argument in Trackier event class is event Id.

You can integrate inbuilt params with the event. In-built param list are mentioned below:-

orderId, revenue, currency, param1, param2, param3 ,param4, param5, param6, param7, param8, param9, param10.

Below are the screenshot of following example

Screenshot[4]

Customs Events -

Customs events are created by user as per their required business logic.

You can create the events in the Trackier dashboard and integrate those events in the app project.

Screenshot[5]

Screenshot 2022-06-29 at 4 09 37 PM

Example code for calling Customs Events.

 public class Script : MonoBehaviour
    {
        // Start is called before the first frame update
        void Start()
        {
            /*While Initializing the Sdk, You need to pass the two arguments in the TrackierSDKConfig.
            you need to pass the Trackier SDK api key in the argument */

            /* Initialize sdk */
            TrackierUnity.start("xxxx-xx-4505-bc8b-xx");

            /* Event Track */
             /*
            * Event Tracking
            <------------->
            * The below code is the example to pass a event to the Trackier SDK.
            * This event requires only 1 Parameter which is the Event ID.
            * Below are the example of built-in events function calling
            * The arguments - "sEMWSCTXeu" passed in the Trackier event class is Events id
            */
            TrackierEvent trackierEvent = new TrackierEvent("sEMWSCTXeu"); //pass your eventid here
            trackierEvent.param1 = "param";
            TrackierUnity.trackierEvent(trackierEvent);
        }

        // Update is called once per frame
        void Update()
        {

        }
    }

Below are the screenshot of above code snippet

Screenshot[6]

Screenshot 2022-07-28 at 9 54 36 AM

Revenue Event Tracking

Trackier allow user to pass the revenue data which is generated from the app through Revenue events. It is mainly used to keeping record of generating revenue from the app and also you can pass currency as well.

    
    public class Script : MonoBehaviour
    {
        // Start is called before the first frame update
        void Start()
        {
            /*While Initializing the Sdk, You need to pass the two arguments in the TrackierSDKConfig.
            you need to pass the Trackier SDK api key in the argument */

            /* Initialize sdk */
            TrackierUnity.start("xxxx-xx-4505-bc8b-xx");

            /* Event Track */
             /*
            * Event Tracking
            <------------->
            * The below code is the example to pass a event to the Trackier SDK.
            * This event requires only 1 Parameter which is the Event ID.
            * Below are the example of built-in events function calling
            * The arguments - "sEMWSCTXeu" passed in the Trackier event class is Events id
            */
            TrackierEvent trackierEvent = new TrackierEvent("sEMWSCTXeu"); //pass your eventid here
            trackierEvent.param1 = "param";
            trackierEvent.revenue = 8.0; //pass your revenue here
            trackierEvent.currency = "Inr"; //pass your currency here
            TrackierUnity.trackierEvent(trackierEvent);
        }

        // Update is called once per frame
        void Update()
        {

        }
    }

Pass the custom params in events

IDictionary<int, object> eventCustomParams = new Dictionary<int, object>();
numberNames.Add(customParam1,XXXXX); 
numberNames.Add(customParam2,XXXXX);
trackierEvent.ev = eventCustomParams;
TrackierUnity.TrackEvent(trackierEvent);
	

Deeplinking Android

Deep linking is a techniques in which the user directly redirect to the specific pages of the application by click on the deeplink url.

There are two types deeplinking

  • Normal deeplinking - Direct deep linking occurs when a user already has your app installed on their device. When this is the case, the deep link will redirect the user to the screen specified in the link.

  • Deferred deeplinking - Deferred deep linking occurs when a user does not have your app installed on their device. When this is the case, the deep link will first send the user to the device app store to install the app. Once the user has installed and opened the app, the SDK will redirect them to the screen specified in the link.

Please check below the Deeplinking scenario

Screenshot 2022-06-22 at 10 48 20 PM

Normal Deep linking

If a user already has your app on their device, it will open when they interact with a tracker containing a deep link. You can then parse the deep link information for further use. To do this, you need to choose a desired unique scheme name.

You can set up a specific activity to launch when a user interacts with a deep link. To do this:

  • Assign the unique scheme name to the activity in your AndroidManifest.xml file.
  • Add the intent-filter section to the activity definition.
  • Assign an android:scheme property value with your preferred scheme name.

For example, you could set up an activity called FirstActivity to open like this:

AndroidManifest.xml


        <activity
            android:name=".Activity.FirstProduct"
            android:exported="true">
        <intent-filter>
            <action android:name="android.intent.action.VIEW" />
            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.BROWSABLE" />
            <data
                android:host="www.trackier.com"
                android:pathPrefix="/product"
                android:scheme="unilink" />
        </intent-filter>
        </activity>

To open your app when a user clicks on a tracker URL, add its scheme name to the Trackier tracker as a deep_link parameter. A tracker URL without any extra information might look like this:

unilink://www.trackier.com/product?dlv=FirstProduct&quantity=10&pid=sms

Deferred Deep linking

Deferred deep linking happened, when a user does not have your app installed on their device. When the user clicks a trackier URL, the URL will redirect them to the Play Store to download and install your app. When the user opens the app for the first time, the SDK will read the deep_link content.

The Trackier SDK opens the deferred deep link by default. just need to add some code in application class just after initilazation of Trackier SDk

Below are the example of the code :-

using UnityEngine;
using System.Collections;
using com.trackier.sdk;
using System;

public class NewMonoBehaviour : MonoBehaviour
{
	// Use this for initialization
	void Start()
	{
        TrackierConfig trackierConfig = new TrackierConfig("abcf2270-xxxxxxxxxx-34903c6e1d53", "development");
        trackierConfig.setDeferredDeeplinkDelegate(DeferredDeeplinkCallback); // Pass for setting the deferred deeplinking 
        TrackierUnity.initialize(trackierConfig);
        Debug.Log("AppKey Initialized");

    }

	// Update is called once per frame
	void Update()
	{
			
	}

    private void DeferredDeeplinkCallback(string deeplinkURL)
    {
        Debug.Log("Deferred deeplink reported!");

        if (deeplinkURL != null)
        {
            Debug.Log("Deeplink URL: " + deeplinkURL); // Getting the deeplink url.
        }
        else
        {
            Debug.Log("Deeplink URL is null!");
        }
    }
}