Unity Quick Start

Current Unity plugin version 4.5.0

The TUNE plugin for Unity provides application session and event logging functionality via the TUNE native SDKs. The TUNE plugin is compatible with Unity 5.3+.

To begin logging sessions and events, first integrate the Unity plugin with your mobile app. After you initiate the MeasureSession method, you can measure in-app events (such as purchases, game levels, and any other user engagement).

Follow this Quick Start to get the Unity plugin up-and-running in no time. If you’re upgrading your app from TUNE Unity plugin version 3.x to 4.x, then please visit Migrating from SDK 3.x to 4.x.

Supported TMC Solutions

The TUNE plugin for Unity supports the following TUNE Marketing Console solutions:

Downloading the Plugin

All of our extensions/plugins are open source and available on Github. To download the Unity plugin, please click the following link.

Unity plugin

Before you can download the TUNE plugin for Unity, make sure to add your app to the Attribution Analytics platform.

Implementation

To implement the downloaded plugin:

  1. Download the Tune.unitypackage file from our GitHub repo.
  2. Open your Unity project.
  3. Go to Assets -> Import Package -> Custom Package and select the Tune.unitypackage to import.
  4. Attach a new C# script to a GameObject in your main scene.
  5. In your GameObject, click Add Component -> New Script.
  6. Edit the new script as follows:
using UnityEngine;
using System.Collections;
using System.Runtime.InteropServices;
using TuneSDK;
 
public class TuneScript : MonoBehaviour {
 
    void Awake() {
        Tune.Init("your_advertiser_ID", "your_conversion_key");
 
        // Check if a deferred deep link is available and handle opening of the deep link as appropriate in the success callback.
        // Uncomment the following line if your TUNE account has enabled deferred deep links
        // Tune.CheckForDeferredDeeplink();
 
        // Uncomment the following line to enable auto-measurement of successful in-app-purchase (IAP) transactions as "purchase" events
        // Tune.AutomateIapEventMeasurement(true);
 
        // Measure initial app open
        Tune.MeasureSession();
    }
 
    void OnApplicationPause(bool pauseStatus) {
        if (!pauseStatus) {
            // Measure app resumes from background
            Tune.MeasureSession();
        }
    }
}

For an example implementation, you may refer to the following files:

  • Tune/Scenes/TUNESampleScene.unity
  • Tune/Scripts/TuneSample.cs

Configuration for Android

Building on Android will require JDK 1.8. You may tell Unity to use this from the menu option Unity -> Preferences -> External Tools -> JDK.

The sample/Assets/Plugins/Android folder includes a working example of AndroidManifest.xml. This example contains the necessary components for the TUNE plugin, simply modify it to suit your needs.

The TUNE plugin for Unity also requires the Google Play Services SDK. To import this automatically, select from your Unity menu TUNE -> Setup -> Import Google Play Services which will import the Google Play Services library into the Plugins/Android folder of your project. In plugin v4.1.1, we automatically package this file with the unitypackage, so you will not need to do any additional import.

Advertising Identifiers

To increase the consistency and ease of attribution, the TUNE plugin for Unity collects device identifiers as described in Unique Identifiers for Attribution.

Android

The Google Advertising ID is automatically collected by the Unity plugin. It requires the following:

  • google-play-services_lib folder or play-services-basement.aar file in Assets/Plugins/Android
  • Inside AndroidManifest.xml‘s <application> tag:
    <meta-data android:name="com.google.android.gms.version"
               android:value="@integer/google_play_services_version" />;

These will be automatically present with the above Android installation instructions.

iOS

The Apple Advertising ID is automatically collected by the Unity plugin.

Things to Keep in Mind

  • The “your_advertiser_ID” and the “your_conversion_key” values correlate with the Advertiser ID and Conversion Key that TUNE provides when you create your Mobile App in Attribution Analytics. For information about the advertiser ID and conversion key, please visit Finding Advertiser ID and Conversion Key.
  • Deferred deep linking functionality is only available in the TUNE plugin for Unity versions 3.11.0+. For information about deferred deeplinking, please visit Implementing a Deferred Deep Link.
  • If your app already has a pre-existing user base (people who have already installed your app), TUNE has several options to flag these users as Pre-Existing Users to prevent attributing these users to a marketing partner. For information about migrating existing users, please visit handle existing users prior to SDK implementation.
  • TUNE SDK v4.0+ for Android & v3.10+ for iOS automatically collects the geo location of the user's device to help improve location-based user segmentation. The location is collected only if the app has already requested and obtained end-user permissions; the TUNE SDK never asks for location access permission from the end-user. For more info, please visit Location Auto-Collection.

Testing & Troubleshooting

To test the Unity plugin implementation in your mobile app, you can do so straight from the Attribution Analytics platform itself rather than creating a test environment. Please visit Testing Your Mobile App.

Measuring Events

After you implement the TUNE plugin for Unity in your mobile app and start logging sessions, you can move on to logging a wide variety of in-app events such as registrations and in-app purchases.

By logging and analyzing in-app events, you can more efficiently optimize both the functionality of your app and your advertising strategies. Bottom line? Understanding how your users interact with your mobile app directly impacts your ability to build effective and profitable advertising campaigns by enabling you to compare retention, engagement, and lifetime value (LTV) to your costs.

Or to build your own custom event, please visit Event Builder.

In-App Events

Achievement Unlocked

Gaining access to additional functionality; generally by completion of a particular event or level.

Add to Cart

Including items in one's virtual shopping cart to be purchased.

Add to Wishlist

Including items in one's virtual list of wanted items not to be readily purchased.

Added Payment Info

Including one's payment information to be used for making purchases.

Checkout Initiated

Starting the checkout process once items have been added to one's cart and ready to complete the purchase.

Content View

Looking at or inspecting content on a page; essentially the rendering of the page.

Invite

Requesting someone to do something; for example, a friend invite or an app invite.

Level Achieved

Completing the necessary requirements to move on to the next stage; generally applies to gaming apps.

Login

The process by which an individual gains access to their account by identifying and authenticating themselves.

Purchase

Completing a purchase transaction in which one has bought an item.

Rated

Assigning a value to something according to a particular scale; e.g. 4 stars.

Registration

The act or process of entering information about one's self to create an account.

Reservation

Arranging to have something (such as a table or seat) held for one's use at a later time.

Search

Actively looking for or seeking out something via a keyword.

Share

Giving others access to something; e.g. sending a link online content.

Spent Credits

Applying accumulated rewards/points as payment for an item.

Tutorial Complete

Finishing a lesson or instructions on how to do/achieve something.

Have a Question? Please contact support@tune.com for technical support.