Xaramin Analytics
This article covers how to handle analytics for Xamarin.
Setting user IDs
1
Braze.getInstance(context).ChangeUser("YOUR_USER_ID");
See the Android integration instructions for an in-depth discussion of when and how to set and change a user ID.
1
2
// C#
Appboy.SharedInstance().ChangeUser("YOUR_USER_ID");
See the iOS integration instructions for an in-depth discussion of when and how to set and change a user ID.
Tracking custom events
1
Braze.getInstance(context).LogCustomEvent("YOUR_EVENT_NAME");
See the Android integration instructions for an in-depth discussion of event tracking best practices and interfaces.
1
2
// C#
Appboy.SharedInstance ().LogCustomEvent ("YOUR_EVENT_NAME");
Implementation Example - logCustomEvent
is utilized within the AppboySampleViewController.cs
within the TestApp.XamariniOS sample application.
See the iOS integration instructions for an in-depth discussion of event tracking best practices and interfaces.
Logging purchases
1
Braze.getInstance(context).LogPurchase("product_id", 100);
See the Android integration instructions for an in-depth discussion of revenue tracking best practices and interfaces.
1
2
// C#
Appboy.SharedInstance ().LogPurchase ("product_id", "USD", new NSDecimalNumber("10"));
Implementation Example - You can see user properties being set in the sample application’s EventsAndPurchasesButtonHandler
method inside AppboySampleViewController.cs
.
See the iOS integration instructions for an in-depth discussion of revenue tracking best practices and interfaces.
Log purchases at the order level
If you want to log purchases at the order level instead of the product level, you can use order name or order category as the product_id
. Refer to our purchase object specification to learn more.
Setting custom attributes
1
2
// C#
Appboy.SharedInstance ().User.FirstName = "YOUR_NAME";
Implementation Example - You can see user properties being set in the sample application’s UserPropertyButtonHandler
method inside AppboySampleViewController.cs
.
See the iOS integration instructions for an in-depth discussion of attribute tracking best practices and interfaces.
Location tracking
- Android: See the Android integration instructions for information on how to support location tracking.
- iOS: See the Xamarin using background location walkthrough and the iOS integration instructions for information on how to support location tracking.