1. Home
  2. Integrations
  3. Android Native Events Setup Guide
  4. Generic Events Across Verticals – Android

Generic Events Across Verticals – Android

We have provided a list of Generic Events with their example usage that are applicable and can be integrated for Applications across all Verticals. Please find them below:

1. Page Views

This is used to track user’s page views in your application.

NOTE: For average page time, you will need this on transition pages so that we can calculate start and end times on the page. Also note that this can generate a lot of traffic and hence cost if the request is large.

You will need to call MTractionEventTracker Class to track the Page views in your Application.

Public static void trackPage(Context context, String pageName);

Sample Code

MTractionEventTracker.trackPage(this.getApplicationContext(), “home”);

2. Registration Event

This is used to track the event triggered when a user has successfully registered an account in your Application.

You will need to call the below method of MTractionEventTracker Class to track the Registration event in your Application.

Public static void trackRegistration(Context context, Registration registration);
Registration registration = new Registration(userId);

 

  • Mandatory parameters (Registration):
    • User Id – Unique User Identifier
  • Optional parameters (Registration):
    • Mobile Number – Mobile Number of the person registering
    • Registration.Gender.XXXXXX can take any value of the Gender, [MALE or FEMALE] based on the sex of the person, registering in your Application
    • Name – Name of the person registering
    • Email Id – Email of the person registering
    • Country Calling Code – Calling Code of the Country, the person registering belongs
    • Page Name – Page that triggered the Event
    • Location – Geolocation of the Event

Sample Code

// Example Longitude & Latitude code (Long / Lat is optional)
LocationManager lm = (LocationManager)getSystemService(Context.LOCATION_SERVICE); 
Location location = lm.getLastKnownLocation(LocationManager.GPS_PROVIDER);

// Example Constructor call with User ID (User ID is mandatory)
Registration registration = new Registration(“123”);

// Examples for other parameters passed with the event (These are optional)
registration.setMobileNumber(8325552002)
.setGender(Registration.Gender.MALE)
.setName(“John77”)
.setEmailId(“john@john.com”)
.setCountryCallingCode(1)
.setPageName(“Account Signup”)
.setLocation(location.getLatitude(), location.getLongitude());

// trackRegistration method call
MTractionEventTracker.trackRegistration(this.getApplicationContext(), registration);

3. Login Event

This is used to track the event triggered when a user has just logged into your Application with his credentials.

You will need to call the below method of MTractionEventTracker Class to track the Login event in your Application.

public static void trackLogin(Context context, Login login);
Login login = new Login(userId);

 

  • Mandatory parameters (Login):
    • User Id – Unique User Identifier
  • Optional parameters (Login):
    • Page Name – Page that triggered the Event
    • Location – Geolocation of the Event

Sample Code

// Example Longitude & Latitude code (Long / Lat is optional)
LocationManager lm = (LocationManager)getSystemService(Context.LOCATION_SERVICE); 
Location location = lm.getLastKnownLocation(LocationManager.GPS_PROVIDER);

// Example Constructor call with User ID (User ID is mandatory)
Login login = new Login(“123”);

// Examples for other parameters passed with the event (These are optional)
login.setPageName(“Home Page”)
.setLocation(location.getLatitude(), location.getLongitude());

// trackLogin method call
MTractionEventTracker.trackLogin(this.getApplicationContext(), login);

4. Rate Event

This is used to track the event triggered when a user has performed a rating in your Application.

You will need to call the below method of MTractionEventTracker Class to track the Rate event in your Application.

Public static void trackRate(Context context, Rate rate);
Rate rate = new Rate(userId, ratingValue, maxRatingValue, identifier, productName);

 

  • Mandatory parameters (Rate):
    • User Id – Unique User Identifier
    • Rating Value – App user’s Rating
    • Maximum Rating Value – Maximum allowed Rating
    • Identifier – Unique Event Identifier
    • Product Name – Name of the product being rated
  • Optional parameters (Rate):
    • Brand – Brand of the product being rated
    • Category – Category of the product being rated
    • Page Name – Page that triggered the Event
    • Location – Geolocation of the Event

Sample Code

// Example Longitude & Latitude code (Long / Lat is optional)
LocationManager lm = (LocationManager)getSystemService(Context.LOCATION_SERVICE); 
Location location = lm.getLastKnownLocation(LocationManager.GPS_PROVIDER);

// Example Constructor call with all the mandatory parameters
Rate rate = new Rate(“123”,4.5, 5, “12345”, “Targus Backpack”);

// Examples for other parameters passed with the event (These are optional)
rate.setBrand(“Targus”)
.setCategory(“Bags”)
.setPageName(“Product rating”)
.setLocation(location.getLatitude(), location.getLongitude());

// trackRate method call
MTractionEventTracker.trackRate(this.getApplicationContext(), rate);

5. Search Event

This is used to track the event triggered when a user has searched for a product/content or travel in your Application.

You will need to call the below method of MTractionEventTracker Class to track the Search event in your Application.

 

Public static void trackSearch(Context context, Search search);
Search search = new Search(userId);

 

  • Mandatory parameters (Search):
    • User Id – Unique User Identifier
  • Optional parameters (Search):
    • Keywords – Keywords used for the Search event
    • Category – Category of the searched item
    • Date From – “From Date”, used in the Search event (Applies for Travel Travel)
    • Date To – “To Date”, used in the Search event (Applicable for Travel Travel)
    • Location From – “From Location”, used in the Search event (Applicable for Travel Travel)
    • Location To – “To Location”, used in the Search event (Applicable for Travel)
    • Class – Class of the searched item (Applicable for Travel vertical)
    • Price From – Starting price range of the searched item
    • Price To – Ending price range of the searched item
    • Discount – Discount information of the searched item
    • Brand – Brand information of the searched item
    • Page Name – Page that triggered the Event
    • Location – Geolocation of the Event

Sample Code (With an Example based on a scenario from the Travel Vertical)

// Example Longitude & Latitude code (Long / Lat is optional)
LocationManager lm = (LocationManager)getSystemService(Context.LOCATION_SERVICE); 
Location location = lm.getLastKnownLocation(LocationManager.GPS_PROVIDER);

// Example Dates to passed in as Optional parameters
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
Date dateFrom = dateFormat.parse("2016-06-17");
Date dateTo = dateFormat.parse("2016-06-24");

// Example Constructor call with User ID (User ID is mandatory)
Search search = new Search(“123”);

// Examples for other parameters passed with the event (These are optional)
search.setKeywords(“Non Stop Flights”)
.setCategory(“Flights”)
.setDateFrom(dateFrom)
.setDateTo(dateTo)
.setLocationFrom(“Singapore”)
.setLocationTo(“New Delhi”)
.setClass(“Economy”)
.setPriceFrom(350.00)
.setPriceTo(750.00)
.setDiscount(10.00)
.setBrand(“Singapore Airlines”)
.setPageName(“Flights Search”)
.setLocation(location.getLatitude(), location.getLongitude());

// trackSearch method call
MTractionEventTracker.trackSearch(this.getApplicationContext(), search);

6. Invite Event

This is used to track the event triggered when a user has invited his/her friend to use your Application.

You will need to call MTractionEventTracker Class to track the Invite event in your Application.

Public static void trackInvite(Context context, Invite invite);
Invite invite = new Invite(userId);

 

  • Mandatory parameters (Invite):
    • User Id – Unique User Identifier
  • Optional parameters (Invite):
    • Description – Additional information about the Event
    • Page Name – Page that triggered the Event
    • Location – Geolocation of the Event

Sample Code

// Example Longitude & Latitude code (Long / Lat is optional)
LocationManager lm = (LocationManager)getSystemService(Context.LOCATION_SERVICE); 
Location location = lm.getLastKnownLocation(LocationManager.GPS_PROVIDER);

// Example Constructor call with User ID (User ID is mandatory)
Invite invite = new Invite(“123”);

// Examples for other parameters passed with the event (These are optional)
invite.setDescription(“Invitation to user id: 567 join my Network”)
.setPageName(“Invite friends”)
.setLocation(location.getLatitude(), location.getLongitude());

// trackInvite method call
MTractionEventTracker.trackInvite(this.getApplicationContext(), invite);

7. Share Event

This is used to track the event triggered when a user has shared information about his/her engagement with the Application either internally or externally.

You will need to call MTractionEventTracker Class to track the Share event in your Application.

 

Public static void trackShare(Context context, Share share);
Share share = new Share(userId);

 

  • Mandatory parameters (Share):
    • User Id – Unique User Identifier
  • Optional parameters (Share):
    • Description – Additional information about the shared item
    • Category – Category of the content shared
    • Identifier – Unique Event Identifier
    • Product Name – Name of the shared item
    • Brand – Brand information of the shared item
    • Page Name – Page that triggered the Event
    • Location – Geolocation of the Event

Sample Code

// Example Longitude & Latitude code (Long / Lat is optional)
LocationManager lm = (LocationManager)getSystemService(Context.LOCATION_SERVICE); 
Location location = lm.getLastKnownLocation(LocationManager.GPS_PROVIDER);

// Example Constructor call with User ID (User ID is mandatory)
Share share= new Share(“123”);

// Examples for other parameters passed with the event (These are optional)
share.setDescription(“Targus Backpack for 13 inch Macbook Pro”)
.setCategory(“Bags”)
.setIdentifier(“12345”)
.setProductName(“Targus Backpack”)
.setBrand(“Targus”)
.setPageName(“Purchase History”)
.setLocation(location.getLatitude(), location.getLongitude());

// trackShare method call
MTractionEventTracker.trackShare(this.getApplicationContext(), share);

8. Payment Information Updated Event

This is used to track the event triggered when a user has updated/saved his payment information on the Application which can be used for his transactions later.

You will need to call MTractionEventTracker Class to track the Payment Information Updated event in your Application.

Public static void trackPaymentInfoUpdated(Context context, PaymentInfoUpdated paymentInfoUpdated);
PaymentInfoUpdated  paymentInfoUpdated = new PaymentInfoUpdated(userId, PaymentInfoUpdated.PaymentMode.CREDIT_CARD);

 

  • Mandatory parameters (Payment Information Updated):
    • User Id – Unique User Identifier
    • PaymentInfoUpdated.PaymentMode.XXXXXX can take any of the predefined values, [CREDIT_CARD or DEBIT_CARD or NET_BANKING or GIFT_CARD or PAYMENT_WALLET]
  • Optional parameters (Payment Information Updated):
    • Page Name – Page that triggered the Event
    • Location – Geolocation of the Event

Sample Code

// Example Longitude & Latitude code (Long / Lat is optional)
LocationManager lm = (LocationManager)getSystemService(Context.LOCATION_SERVICE); 
Location location = lm.getLastKnownLocation(LocationManager.GPS_PROVIDER);

// Example Constructor call with all the mandatory parameters
PaymentInfoUpdated paymentInfoUpdated = new PaymentInfoUpdated (“123”, PaymentInfoUpdated.PaymentMode.CREDIT_CARD);

// Examples for other parameters passed with the event (These are optional)
paymentInfoUpdated.setPageName(“Payment Information”)
.setLocation(location.getLatitude(), location.getLongitude());

// trackPaymentInfoUpdated method call
MTractionEventTracker.trackPaymentInfoUpdated(this.getApplicationContext(), paymentInfoUpdated );

9. App Exit Event

This is used to track the event triggered when a user has quit from the Application.

You will need to call MTractionEventTracker Class to track the App Exit event in your Application.

Public static void trackAppExit(Context context, AppExit appExit);
AppExit appExit = new AppExit(userId);

 

  • Mandatory parameters (App Exit):
    • User Id – Unique User Identifier
  • Optional parameters (App Exit):
    • Location – Geolocation of the Event
    • Page Name – Page that triggered the Event

Sample Code

// Example Longitude & Latitude code (Long / Lat is optional)
LocationManager lm = (LocationManager)getSystemService(Context.LOCATION_SERVICE); 
Location location = lm.getLastKnownLocation(LocationManager.GPS_PROVIDER);

// Example Constructor call with User ID (User ID is mandatory)
AppExit appExit = new AppExit(“123”);

// Examples for other parameter passed with the event (This is optional)
appExit.setLocation(location.getLatitude(), location.getLongitude())
       .setPageName(“Home Page”);

// trackAppExit method call
MTractionEventTracker.trackAppExit(this.getApplicationContext(), appExit);

Additionally, you can implement custom events to track specific behavior on your application. Please follow the documentation (with example): Custom Events Setup Guide

 

Was this article helpful to you? Yes No

How can we help?