Singular Android SDK | |
---|---|
Download |
Singular Android SDK version 12.1.1 (see Change Log) |
Compatibility |
Android 4.0.1 (Ice Cream Sandwich) and higher
|
Sample App | Review our sample app for an example of a complete SDK integration based on best practices. |
Integration Guides |
Tracking Events
Singular can collect data about in-app events to help analyze the performance of your campaigns and measure KPIs. For example, your organization may want to collect data about user logins, registrations, tutorial completions, or leveling up in a gaming app.
Singular supports a variety of standard events. These commonly used events are often supported by ad networks for reporting and optimization. Another advantage is that when you use standard event names, Singular recognizes them automatically and adds them to the Events list without you having to define them manually. We recommend using standard events whenever possible.
The list of events sent to Singular (with the accompanying attributes) should be compiled by the UA/marketing/business team based on your organization's marketing KPIs. The business team can follow the guide at How to Track In-App Events: Guide For Singular Attribution Customers.
With each event you track, you can pass various attributes. See the recommended standard attributes per event.
In your code, send events to Singular using the eventJSON or event methods (we recommend eventJSON for readability).
- For standard events, use the event's Android name as it appears in the list of standard events and attributes for the Android SDK, e.g., sngTutorialComplete.
- See the code examples below.
- For custom events (events that your organization wants to measure that do not match any of Singular's standard events), use any string you like that complies with the limitations.
Singular.eventJSON Method | |
---|---|
Description | Report a user event to Singular with additional information in JSONObject format. |
Signature |
Singular.eventJSON(String name, JSONObject args)
Note: 'args' is a JSONObject containing one or more key-value pairs. The key is a string and the value can be any type that's allowed as a JSONObject value.
|
Usage Example |
|
Singular.event Method | |
Description | Report a user event to Singular with or without additional information. |
Signature |
Singular.event(String eventName) Note: 'args' is one or more key-value pairs (see the example below). The key is a string and the value can be any type that's allowed as a JSONObject value (i.e., JSONObject, JSONArray, String, Boolean, Integer, Long, Double or NULL). The 'args' list must contain an even number of elements or the event will be rejected by Singular. |
Usage Example |
|
Notes:
- We highly recommend passing event names and attributes in English to guarantee compatibility with third-party partners and analytics solutions if you plan to use them.
- Event names are limited to 32 ASCII characters. Strings in non-ASCII characters have to be under 32 bytes once converted to UTF-8.
- Attributes and values are limited to 500 ASCII characters.
Tracking Revenue
Singular can collect data about revenue gained through the app to help analyze the performance and ROI of your campaigns. Singular will make the data available to you in reports, log export, and postbacks.
When reporting revenue events to Singular, we recommend passing the purchase object received from the billing library. This has two advantages:
- Singular gets all the details of the transaction, which enriches your Singular reports.
- Singular gets the transaction receipt from Google which can be used to validate the transaction in the context of fighting in-app fraud.
Use the revenue and customRevenue methods to report events. CustomRevenue allows you to pass a custom event name, so that you'll be able to view revenue in Singular reports broken down by the different types of revenue events.
Note: Any revenue reported in a different currency will be auto-converted to your organization's preferred currency, as set in your Singular account.
Singular.revenue Method | |
---|---|
Description | Send a revenue event to Singular with optional additional information. |
Signature |
Singular.revenue(String currency, double amount, Object purchase) Note:
|
Usage Example |
|
Singular.customRevenue Method | |
Description | Send a revenue event to Singular with an event name and optional additional information. |
Signature |
Singular.customRevenue(String eventName, String currency, double amount, Object purchase) Note:
|
Usage Example |
|
Reporting Revenue without the Purchase Object
While we strongly recommend reporting revenue events the way described above, you can also use revenue and customRevenue without passing the purchase object. Instead, you pass the currency and amount of the transaction, and optional product details.
Note that when reporting revenue events this way, Singular does not get the purchase receipt and cannot validate the transaction.
Singular.revenue Method (Without Purchase Object) | |
---|---|
Description |
Send a revenue event to Singular with optional additional information. |
Signature |
Singular.revenue(String currency, double amount, String productSKU, String productName, String productCategory, int productQuantity, double productPrice) Singular.revenue(String currency, double amount) Note: Pass currency as a three-letter ISO 4217 currency code, such as “USD”, “EUR”, or “INR". |
Usage Example |
|
Singular.customRevenue Method (Without Purchase Object) | |
Description | Send a revenue event to Singular with an event name and optional additional information. |
Signature |
Singular.customRevenue(String eventName, String currency, double amount, String productSKU, String productName, String productCategory, int productQuantity, double productPrice) Note: Pass currency as a three-letter ISO 4217 currency code, such as “USD”, “EUR”, or “INR". |
|
Integration Guides |