unity-countly is a Unity 3D plugin for facilitating integration with Countly Mobile Analytics.
Although there is countly-sdk-unity, I believe it does not match the quality of the iOS and Android versions provided by Countly Team.
unity-countly provides the following advantages over countly-sdk-unity:
- More robust (for instance if you run
Countly.Instance.OnStart()
,Countly.Instance.OnStop()
more than once you will get errors). - Countly SDK 2.0 compliant.
- Understands when your app goes to background and comes to foreground.
- Events that could not be delivered are stored so that they can be delivered next time your app starts.
- Detects mobile carrier name.
- Detects locale properly.
- Unity 3.x Pro or above.
The change log contains the list of changes and latest version information of each package.
- Create a
CountlyManager
object in your scene. - Add the
Assets/Plugins/Countly/CountlyManager.cs
component to it. - Set the App Key parameter.
If you leave App Key
blank, you can initialize Countly at any time
using CountlyManager.Init("your_app_key_here"`);
CountlyManager.Emit("dummy_event", 1);
or
double count = 5.0;
CountlyManager.Emit("tap", 1, duration);
or
CountlyManager.Emit("clear", 1,
new Dictionary<string, string>()
{
{"level", "1"},
{"difficulty", "normal"}
});
or
double price = 123.4;
CountlyManager.Emit("purchase", 1, price,
new Dictionary<string, string>()
{
{"purchase_id", "product01"},
});
or ultimately
Countly.Event e = new Countly.Event();
e.Key = "purchase";
e.Count = 1;
e.Sum = 123.4;
e.Segmentation =
new Dictionary<string, string>()
{
{"purchase_id", "product01"},
});
CountlyManager.Emit(e);
- Found a bug?
- Want to contribute and add a new feature?
Please fork this project and send me a pull request!
unity-countly is licensed under the MIT license:
www.opensource.org/licenses/MIT
Copyright (c) 2014 Mario Freitas. See LICENSE.txt for further details.