1. Home
  2. Integrations
  3. Android Native Events Setup Guide
  4. Social Applications – Android

Social Applications – Android

We have provided a list of Events with their example usage that can be integrated for Social Applications. Please find them below:

1. Purchase Event

This is used to track the successful Purchase events or paid subscription to the Application.

You will need to call the below method of MTractionEventTracker Class to track the In-App Purchase event in your Application.

Public static void trackPurchase(Context context, Purchase purchase);
// Product List Array Definition
List productList = new ArrayList();

// Product Constructor Call
Product product1 = new Product(productIdentifier, productName, price, quantity);

  • Mandatory parameters (Product): 
    • Product Identifier – Unique Product Identifier
    • Product Name – Name of the Product
    • Price – Price of the Product
    • Quantity – Quantity of the Product being Purchased
  • Optional parameters (Product):
    • Brand – Brand Name of the Product
    • Product Discount – Discount applied for the Product
    • Category – Product Category
// Adding the product to the Product List
productList.add(product1);

// Purchase Constructor Call
Purchase purchase = new Purchase(userId, revenue, Purchase.PaymentMode.DEBIT_CARD, locale, transactionId, Purchase.Frequency.XXX, productList);

  • Mandatory parameters (Purchase): 
    • User Id – Unique User Identifier
    • Revenue – Total Revenue generated from this Purchase event
    • Purchase.PaymentMode.XXXXXX can take any of the predefined values for payment methods, [CREDIT_CARD or DEBIT_CARD or NET_BANKING or GIFT_CARD or PAYMENT_WALLET]
    • Locale – Currency code used for this purchase. We can get currency code information precisely in either of the following ways: 
      1. Default from device configuration:
        Locale locale = Locale.getDefault();

        Note: Recommended for more accuracy.

      2. Custom setting:
        Locale locale = new Locale("JA"/*Language Code*/, "JP" /*Country Code*/);

        Note: Click here to view the list of Country codes (ISO-3166) & Language codes (ISO-639).

    • Transaction Id – Unique Purchase Transaction Identifier
    • Purchase.Frequency.XXXXXX can take any of the predefined values for payment frequency, [ONCE or RECURRING] representing One Time Payment or Subscription based Payment respectively
    • Product List – Array of the list of products purchased
  • Optional parameters (Purchase):
    • Loyalty – Loyalty points applied on the Purchase
    • Overall Discount – Discount applied for the Purchase
    • Service Charge – Service Charge applied for the Purchase
    • 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);

// Product List Array Definition
List productList = new ArrayList();

// Example Product Constructor Call with the mandatory parameters
Product product1 = new Product(“12345”, “Yearly Subscription”, 14.99, 1);

// Examples for other parameters passed for the Product Class (These are optional)
product1.setBrand(“Premium Account”)
        .setCategory("Annual Subscription") 
        .setProductDiscount(5.00);

// Adding the product to the Product List
productList.add(product1);

// Example Purchase Constructor Call with the mandatory parameters
Purchase purchase= new Purchase(“123”, 14.99, Purchase.PaymentMode.DEBIT_CARD Locale.getDefault(), “1000123” , Purchase.Frequency.RECURRING, productList);

// Examples for other parameters passed for the Purchase Class (These are optional)
purchase.setLoyalty(350.00)
.setOverallDiscount(5.00)
.setServiceCharge(4.99)
.setLocation(location.getLatitude(), location.getLongitude());

// trackPurchase method call
MTractionEventTracker.trackPurchase(this.getApplicationContext(), purchase);

2. Paid Subscription Deactivated Event

This is used to track when the User has unsubscribed from any of the services of the Social Application.

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

Public static void trackPaidSubscriptionDeactivated(Context context, PaidSubscriptionDeactivated pSubsDeactivate);
PaidSubscriptionDeactivated  pSubsDeactivate = new PaidSubscriptionDeactivated(userId);

  • Mandatory parameters (Paid Subscription Deactivated): 
    • User Id – Unique User Identifier
  • Optional parameters (Paid Subscription Deactivated): 
    • 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)
PaidSubscriptionDeactivated pSubsDeactivate = new PaidSubscriptionDeactivated(“123”);

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

// trackPaidSubscriptionDeactivated method call
MTractionEventTracker.trackPaidSubscriptionDeactivated(this.getApplicationContext(), pSubsDeactivate);

3. Profile Updated Event

This is used to track the event triggered when the user has updated his profile information on the Application.

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

Public static void trackProfileUpdated(Context context, ProfileUpdated profileUpdated);
ProfileUpdated  profileUpdated = new ProfileUpdated(userId, category);

  • Mandatory parameters (Profile Updated): 
    • User Id – Unique User Identifier
    • Category – Category/Section of the profile update
  • Optional parameters (Profile 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 the mandatory parameters
ProfileUpdated profileUpdated = new ProfileUpdated (“123”, “Personal Section”);

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

// trackProfileUpdated method call
MTractionEventTracker.trackProfileUpdated(this.getApplicationContext(), profileUpdated);

4. Friends Added Event

This is used to track the event triggered when the user has added a new friend to his list on the Application.

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

Public static void trackFriendsAdded(Context context, FriendsAdded frdAdded);
FriendsAdded  frdAdded = new FriendsAdded(userId);

  • Mandatory parameters (Friends Added): 
    • User Id – Unique User Identifier
  • Optional parameters (Friends Added):
    • FriendsAdded.Gender.XXXXXX can take any value of the Gender, [MALE or FEMALE] based on the sex of the person, being added as a friend
    • Age – Age of the person being added
    • Pagename – Page that triggered the Event
    • Location – Geolocation of the Event
    • Description – Event Description

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)
FriendsAdded frdAdded = new FriendsAdded(“123”);

// Examples for other parameters passed with the event (These are optional)
frdAdded.setDescription(“Friend request sent to id: 567”) 
   .setGender(FriendsAdded.Gender.FEMALE)
   .setAge(27)
   .setPageName(“Recommended Friends”)
   .setLocation(location.getLatitude(), location.getLongitude());

// trackPaidSubscriptionDeactivated method call
MTractionEventTracker.trackFriendsAdded(this.getApplicationContext(), frdAdded);

5. Chatted Event

This is used to track the private or group chat event initiated by the user to other user(s) on the Application.

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

Public static void trackChatted(Context context, Chatted chatted);
Chatted  chatted = new Chatted(userIdFrom, userIdTo);

  • Mandatory parameters (Chatted): 
    • User Id From – Unique Identifier of the User who initiated the Chat
    • User Id To  – Unique Identifier of the User who received the Chat
  • Optional parameters (Chatted): 
    • Chatted.ChatType.XXXXXX can take any value of the types of the chat available, [DIRECT_CHAT or GROUP_CHAT]
    • 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 the mandatory parameters
Chatted  chatted = new Chatted (“123”, ”567”);

// Examples for other parameters passed with the event (These are optional)
chatted.setChatType(Chatted.ChatType.DIRECT_CHAT) 
   .setPageName(“Private Chat”)
   .setLocation(location.getLatitude(), location.getLongitude());

// trackChatted method call
MTractionEventTracker.trackChatted(this.getApplicationContext(), chatted);

6. New Group Created Event

This is used to track the event triggered when an user has created a group in your Application.

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

Public static void trackNewGroupCreated(Context context, NewGroupCreated nGrpCreated);
NewGroupCreated  nGrpCreated = new NewGroupCreated(userId);

  • Mandatory parameters (New Group Created): 
    • User Id – Unique User Identifier
  • Optional parameters (New Group Created): 
    • Quantity – Size of the Group created
    • 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)
NewGroupCreated nGrpCreated = new NewGroupCreated(“123”);

// Examples for other parameters passed with the event (These are optional)
nGrpCreated.setQuantity(50) 
.setPageName(“Create group”)
.setLocation(location.getLatitude(), location.getLongitude());

// trackNewGroupCreated method call
MTractionEventTracker.trackNewGroupCreated(this.getApplicationContext(), nGrpCreated);

7. Call Placed Event

This is used to track the call event initiated by an user to another user on the Application.

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

Public static void trackCallPlaced(Context context, CallPlaced callPlaced);
CallPlaced  callPlaced = new CallPlaced(userIdFrom, userIdTo);

  • Mandatory parameters (Call Placed Item): 
    • User Id From – Unique Identifier of the User who initiated the Call
    • User Id To – Unique Identifier of the User who received the Call
  • Optional parameters (Call Placed Item): 
    • Pagename – 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 the mandatory parameters
CallPlaced  callPlaced = new CallPlaced (“123456789”, ”87654321”);

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

// trackCallPlaced method call
MTractionEventTracker.trackCallPlaced(this.getApplicationContext(), callPlaced);
Was this article helpful to you? Yes No

How can we help?