Javascript Quick Start

Current JavaScript SDK Version 3.9.1

The TUNE SDK for JavaScript provides application session and event logging functionality. The JavaScript SDK is available in the form of a single .js file that you simply include in your HTML file.

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

If you’re not embedding your HTML5 experience into a native app but instead, are building a stand-alone web experience, use our pixel and cookie tracking method instead.

Follow this Quick Start to get the TUNE SDK up and running in no time.

Supported TMC Solutions

The TUNE SDK for Javascript supports the following TUNE Marketing Console solutions:

  • Attribution Analytics
  • App Store Analytics

Downloading the SDK

The JavaScript SDK is 95 KB in size. It is available at https://s3.amazonaws.com/hasfiles/scripts/attribution-3.9.1.js. You may reference it directly or download it for bundling with your app.

Before you implement the TUNE SDK, make sure to add your app to the Attribution Analyitcs platform.

Implementation

To implement the downloaded SDK, add the following JavaScript code to your main HTML file:

<script src="https://s3.amazonaws.com/hasfiles/scripts/attribution-3.9.1.js" type="text/javascript"></script>
<script type="text/javascript">
// <![CDATA[
    window.onload = function() {
        MobileAppTracker.init({"advertiserId": "your_advertiser_ID",
                               "conversionKey": "your_conversion_key",
                               "packageName":  "com.example.appname”,             // your app's bundle ID
                               "sdkPlatform":  MobileAppTracker.PLATFORM_ANDROID, // or PLATFORM_IOS or PLATFORM_WINDOWS
                               "appVersion": "1"                                  // your app's version string
                               });
 
        // Set device identifiers here.
        // See https://developers.tune.com/sdk/passing-native-device-identifiers-to-javascript.
 
        // Start measuring session
        MobileAppTracker.measureSession();
    }
// ]]>
</script>

Things to Keep in Mind

The “your_advertiser_ID” value correlates with the Advertiser ID that TUNE provides when you create your Mobile App in Attribution Analytics. For information about the advertiser ID, please visit Finding Advertiser ID and Conversion Key.

Your app’s version string (or build number) is used to determine when users have updated your app.

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.

To increase the consistency and ease of attribution, consider collecting device identifiers as described in Unique Identifiers for Attribution. You can also pass native device identifiers into your javascript from your native shell.

To measure re-engagement, you must collect deeplink info from your native code.

To pass the Google Play referrer, create your own receiver for the install referrer, get the referrer value, and then pass it into the JavaScript from native code, like you would with the device identifiers or re-engagement values. The SDK provides setReferrer for this value.

Testing & Troubleshooting

To test the TUNE SDK 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 SDK 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

No Comments

Leave a reply