Adding a Try to Buy feature increases your chance of sale by 82%


In recent post I talked about the benefit of adding Try to Buy 

With the Windows store we have found over 82% of apps which are offered as a trial convert to a purchase.

image

The try/buy option is a great USP for  Windows and Windows Phone stores each make it very simple to implement such an experience.

global_167779742Try/Buy was also a recent question I had from the London Unity User Group Porting sessions we held.

 unity

Unity3d includes a simple API in its platform to check for a trial license from the store platform.

Here is a nice little step by step guide of how to get started with Unity3d and build a try to buy option within your game

Step 1 Decide on your trial method!

Is it going to be:

  • 1 Level
  • 1 day with unlimited access to features?
  • 7 days with unlimited access to features?
  • Unlimited with limited features?
  • Somewhere in between?

Step 2 – Lets build it

Unity3d has included a simple API for probing the license information for the game from the Store platform. I wasn’t able to find any documentation for the API on the Unity docs site,

   1: using System;
   2: using UnityEngine;
   3:  
   4: namespace UnityEngine.Windows
   5: {
   6:     public sealed class LicenseInformation
   7:     {
   8:         public LicenseInformation();
   9:  
  10:         public static bool isOnAppTrial { get; }
  11:  
  12:         [WrapperlessIcall]
  13:         public static string PurchaseApp();
  14:     }
  15: }

Within your game you will want to query this function and call the API to see if I need to setup the purchase mode or the player can just proceed with normal and use the trail gameplay.

In a Unity3d game, there is a GameController object that will persist across scenes.

We recommend you setup this listener here.

In the file we need to store the status of trial mode in a public static field, so that other scripts that query it to limit features in the game.

   1: public static bool IsTrial = true;
   2:     void Awake()
   3:     {
   4:         GameObject.DontDestroyOnLoad(this); // cause this object to persist
   5:  
   6: #if UNITY_WINRT
   7:         IsTrial = UnityEngine.Windows.LicenseInformation.isOnAppTrial;
   8: #endif
   9:     }

What we now need to do is add a buy button to the GUI.

What we want to happen is when the player presses the BUY button, it will call PurchaseApp() to launch the Store purchasing process.

   1: void OnGUI()
   2:     {
   3:         if (IsTrial)
   4:         {
   5:             if (GUI.Button(new Rect(50, 30, 100, 25), "Buy me!"))
   6:             {
   7: #if UNITY_WINRT || WINDOWS_PHONE
   8:                 var receipt = UnityEngine.Windows.LicenseInformation.PurchaseApp();
   9:                 IsTrial = false;
  10: #endif
  11:             }
  12:         }
  13:     }

Dont worry if your debugging at this PurchaseApp doesn’t return anything at all. You will get an empty string – This is simply because your debugging your app against a app that HAS NOT BEEN PUBLISHED YET.

So the key thing here is that this API appears to just be a fire-and-forget, so put in some logic to recheck the trial mode state when FixedUpdate runs, but only after 1 second has passed. So, while the app is in trial mode, we will check for a change every 1 second.

   1: void FixedUpdate()
   2:     {
   3:         if (IsTrial && (Time.realtimeSinceStartup - _lastTrialCheck) >= 1f)
   4:         {
   5:             _lastTrialCheck = Time.realtimeSinceStartup;
   6:  
   7:             // we'll detect if the trial state has changed
   8:             if (UnityEngine.Windows.LicenseInformation.isOnAppTrial != IsTrial)
   9:             {
  10: #if UNITY_WINRT
  11:                 IsTrial = UnityEngine.Windows.LicenseInformation.isOnAppTrial;
  12: #endif
  13:             }
  14:         }
  15:     }

As a reference here’s the full source for a sample GameController class.

   1: using UnityEngine;
   2: using System.Collections;
   3:  
   4: public class GameController : MonoBehaviour {
   5:  
   6:     public static bool IsTrial = true;
   7:  
   8:     private float _lastTrialCheck = 0f;
   9:  
  10:     void Awake()
  11:     {
  12:         GameObject.DontDestroyOnLoad(this); // cause this object to persist
  13:  
  14: #if UNITY_WINRT
  15:         IsTrial = UnityEngine.Windows.LicenseInformation.isOnAppTrial;
  16: #endif
  17:     }
  18:  
  19:     void FixedUpdate()
  20:     {
  21:         if (IsTrial && (Time.realtimeSinceStartup - _lastTrialCheck) >= 1f)
  22:         {
  23:             _lastTrialCheck = Time.realtimeSinceStartup;
  24:  
  25:             // we'll detect if the trial state has changed
  26:             if (UnityEngine.Windows.LicenseInformation.isOnAppTrial != IsTrial)
  27:             {
  28: #if UNITY_WINRT
  29:                 IsTrial = UnityEngine.Windows.LicenseInformation.isOnAppTrial;
  30: #endif
  31:             }
  32:         }
  33:     }
  34:  
  35:     void OnGUI()
  36:     {
  37:         if (IsTrial)
  38:         {
  39:             if (GUI.Button(new Rect(50, 30, 100, 25), "Buy me!"))
  40:             {
  41: #if UNITY_WINRT || WINDOWS_PHONE
  42:                 var receipt = UnityEngine.Windows.LicenseInformation.PurchaseApp();
  43:                 IsTrial = false;
  44: #endif
  45:             }
  46:         }
  47:     }
  48: } 
Comments (1)

  1. Rob Targosz says:

    Hi Lee,

    Your title is a bit misleading. Saying, "Adding a Try to Buy feature increases your chance of sale by 82%" and then "With the Windows store we have found over 82% of apps which are offered as a trial convert to a purchase." aren't the same thing. I'm sure some apps that don't have trial to paid still have sales, right? 😉

    Thanks for the post, though. I'm tweeting it out tomorrow!

    -Rob