Request the following from support@netminers.net:
- The latest Netminers tracking API for Android
- An Account id
- A breadcrumb version
The following example demonstrates the basic usage of Netminers Android API.
public class MainActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); // First initialize the API with our ACCOUNTID and breadcrumb version. NMTracker.init(this, "ACCOUNTID", "1"); // Send our first event, pageview, to register the app has started. NMTracker.postPageView( "My App/Start", // Event category "http://myandroidapp.company.com" // Namespace ); } /** * Tracking a purchase */ public void buyLicense(View view) { NMTracker.postCommerceAddItem( "Babelfish", // Product name "42", // Product SKU/ID "http://myandroidapp.company.com", // Namespace 10, // Unit price 1 // Quantity ); } /** * Tracking the click of a Tip a friend button */ public void tipAFriend(View view) { NMTracker.postPageView( "My App/My View/Tip a friend", // Product name "http://myandroidapp.company.com" // Namespace ); }
Properties
Every tracking method has a variant taking a Map called properties. For example:
void postPageView(String breadCrumb, String nameSpace, Map<String, Object> properties )
The Map can contain useful segmentation categories such as
- Gender: Male / Female
- Age: 0-25 / 26-30 /31-45/ ...
- Color: Red / white / ...
Categories should always be chosen wisely since queries in Netminers Insight may take a performance hit. Keep categories to a minimum and make them discreete and aim for low cardinality / member count. For example, track a login success action while adding additional information about the gender of a person who logged in.
Map<String, Object> properties = new HashMap<String, Object>(); properties.put("Gender", "Male"); NMTracker.postPageView("My app/Login/Success", "http://myandroidapp.company.com", properties);
Initiation
void init(Context context, String accountId, String versionBreadCrumb)
Tracking methods
- void postPageView(String breadCrumb, String nameSpace)
- void postPageView(String breadCrumb, String nameSpace, Map properties)
- void postCommerceAddItem(String productName, String productId, String nameSpace, double unitPrice, int quantity)
- void postCommerceAddItem(String productName, String productId, String nameSpace, double unitPrice, int quantity, Map properties)
- void postFieldChange(String fieldName, String nameSpace, String value)
- void postFieldChange(String fieldName, String nameSpace, String value, Map properties)
- void postOther(String breadCrumb, String nameSpace)
- void postOther(String breadCrumb, String nameSpace, Map properties)