This guide will help you install the CleverTap Unity SDK, track your first user event, and see this information in the CleverTap dashboard.
You can install the CleverTap Unity SDK using the .unitypackage
or as a local package through the Unity Package Manager (UPM).
- Download the latest CleverTap Unity package.
- Import the
.unitypackage
into your Unity project via Assets > Import Package > Custom Package.
Clone the latest CleverTap Unity SDK release and import it as a local package through the Unity Package Manager.
CleverTap API can be accessed anywhere in your project by calling the static CleverTap class. Initialize CleverTap using your CleverTap Account ID, Token, and Region.
CleverTap.LaunchWithCredentialsForRegion("YOUR_CLEVERTAP_ACCOUNT_ID", "YOUR_CLEVERTAP_ACCOUNT_TOKEN", "CLEVERTAP_ACCOUNT_REGION");
CleverTap.EnablePersonalization();
Handle callbacks by adding an event listener through CleverTap static events.
CleverTap.OnCleverTapDeepLinkCallback += YOUR_CALLBACK_METHOD;
CleverTap.OnCleverTapProfileInitializedCallback += YOUR_CALLBACK_METHOD;
CleverTap.LaunchWithCredentialsForRegion("YOUR_CLEVERTAP_ACCOUNT_ID", "YOUR_CLEVERTAP_ACCOUNT_TOKEN", "CLEVERTAP_ACCOUNT_REGION");
CleverTap.EnablePersonalization();
Dictionary<string, string> newProps = new Dictionary<string, string>();
newProps.Add("Name", "Jack Montana");
newProps.Add("Identity", "61026032");
newProps.Add("Email", "[email protected]");
newProps.Add("Phone", "+14155551234");
newProps.Add("Gender", "M");
CleverTap.ProfilePush(newProps);
List<string> stringList = new List<string> { "India", "USA" };
CleverTap.ProfileSetMultiValuesForKey("Visited Location", stringList);
List<string> stringList = new List<string> { "India" };
CleverTap.ProfileRemoveMultiValuesForKey("Visited Location", stringList);
List<string> stringList = new List<string> { "India", "USA" };
CleverTap.ProfileAddMultiValuesForKey("Visited Location", stringList);
CleverTap.ProfileAddMultiValueForKey("Visited Location", "India");
Dictionary<string, string> newProps = new Dictionary<string, string>();
newProps.Add("email", "[email protected]");
newProps.Add("Identity", "123456");
newProps.Add("Name", "Jack Montana");
newProps.Add("Phone", "+14155551234");
newProps.Add("Gender", "M");
CleverTap.OnUserLogin(newProps);
string cleverTapID = CleverTap.ProfileGetCleverTapID();
CleverTap.ProfileIncrementValueForKey("add_int", 2);
CleverTap.ProfileIncrementValueForKey("add_double", 3.5);
CleverTap.ProfileDecrementValueForKey("minus_int", 2);
CleverTap.ProfileDecrementValueForKey("minus_double", 3.5);
For more detailed instructions, visit the Unity User Profiles.
CleverTap.RecordEvent("Product Viewed");
Dictionary<string, object> props = new Dictionary<string, object>();
props.Add("Product Name", "Casio Chronograph Watch");
props.Add("Category", "Mens Accessories");
props.Add("Price", 59.99);
props.Add("Date", new DateTime());
CleverTap.RecordEvent("Product Viewed", props);
Dictionary<string, object> chargedProps = new Dictionary<string, object>();
chargedProps.Add("Total Amount", 300);
chargedProps.Add("Payment Mode", "Credit Card");
chargedProps.Add("Charged ID", 24052013);
List<Dictionary<string, object>> items = new List<Dictionary<string, object>>();
Dictionary<string, object> item1 = new Dictionary<string, object>();
item1.Add("Product Category", "Books");
item1.Add("Book Name", "The Millionaire next door");
item1.Add("Quantity", 1);
items.Add(item1);
Dictionary<string, object> item2 = new Dictionary<string, object>();
item2.Add("Product Category", "Books");
item2.Add("Book Name", "Achieving inner zen");
item2.Add("Quantity", 1);
items.Add(item2);
CleverTap.RecordChargedEvent(chargedProps, items);
For more detailed instructions, visit the CleverTap Unity SDK Quick Start Guide.