Getting started with Android SDK

Convertedin SDK for events and push notifications is a powerful tool for developers to create engaging and personalized experiences for your app users. With this SDK, developers can easily track user behavior and send targeted push notifications to drive engagement and increase retention. Push notifications allow developers to reach users even when they're not actively using the app, keeping them up to date with the latest news, updates, and promotions. By leveraging Convertedin SDK for events and push notifications, developers can create more meaningful and impactful experiences for their users, leading to higher engagement, increased user satisfaction, and ultimately, greater success for their app.

Installation

The Android SDK is compatible with apps supporting Android API level 21 and above. Apps can be written using Kotlin or Java 8.

Getting started with the Android SDK requires five steps:

Using Github Library

  1. ​Adding the dependency to your Gradle files.

  2. ​Initialize the SDK with your Pixel Id and store url.

  3. Authenticate user by Sending user data.

  4. Track user events and actions through your app.

  5. ​Initialize push notifications and configure it.

Manual Download

  1. Downloading and importing the SDK

  2. ​Adding the dependency to your Gradle files.

Step 1: Adding the dependency to your Gradle files.

Once you acquire a username and password from Convertedin, you can access the repository that has the SDK. Add the following snippet to your root build.gradle file and you will be able to resolve the library.

allprojects {
    repositories {
           maven { url 'https://jitpack.io' }
    }
}

Then, in the build.gradle file for the project for which you would like to include the SDK, add:

dependencies {
    implementation 'com.github.convertedin:android-pixel-sdk:1.4'
}

Step 2: Initialize the SDK with your Pixel Id and store url.

Initialize the SDK using this method

ConvertedInSdk().initialize(this,"Your pixel id", "Your store url")
//you can get pixel id and stire id from the dashboard

Step 3: Authenticate user by Sending user data.

The "Identify User" API in the Convertedin SDK allows developers to track and identify users across different devices and sessions. When a user logs in or creates an account, the developer can use the Identify User API to associate a unique identifier with that user.

This identifier can then be used to track the user's actions and behavior throughout their usage of the application. For example, if a user makes a purchase or completes a form, the Identify User API can associate that action with the user's unique identifier.

By using the Identify User API, developers can gain valuable insights into their user's behavior, preferences, and interests. This information can then be used to improve the user experience, personalize content, and increase user engagement and retention.

Additionally, the Identify User API can also be used to implement security measures such as authentication and authorization, by verifying that a user is who they claim to be and granting them access to certain features or content.

Overall, the Identify User API is a powerful tool for developers to understand and optimize their user's experience, as well as provide a more secure and personalized platform for their users.

Identify user using this method

ConvertedInSdk().identifyUser(“email”,”phone”,”countryCode”)
//You can enter either email or phone number and country code  

You can enter either email or phone number and country code

Step 4: Track user events and actions through your app.

Tracking user events and actions through your app is an essential component of app development and user analysis. By monitoring user actions and events, developers can gain valuable insights into how users interact with their app, what features they use most often, and where they encounter problems or difficulties.

To track user events and actions through your app, you can Convertedin SDK. it will allow you to track user behavior in real-time and provide detailed reports and analytics on user engagement, retention, and conversion.

Typically, the process of tracking user events and actions involves the following steps:

  1. Define the events you want to track: Before you can start tracking user events, you need to identify the specific actions or behaviors that you want to monitor. For example, you might want to track when a user completes a registration form or makes a purchase.

  2. Instrument your app with tracking code: Once you have identified the events you want to track, you need to add tracking code to your app to collect data on user behavior. This code can be added to specific screens or features of your app to track when users perform certain actions.

  3. Send data to our SDK: Once the tracking code is implemented, the data on user events and actions is sent to us, where it is stored and analyzed. From there, you can generate reports and dashboards to visualize user behavior and identify areas for improvement.

By tracking user events and actions, developers can make data-driven decisions and improve the user experience of their app. Whether you're looking to optimize conversion rates, improve user engagement, or identify areas for improvement, event tracking can provide valuable insights into how users interact with your app.

To add event you can use this method

ConvertedInSdk().addEvent("event name","Currency","Total","products")
//where products is an arraylist of EventContent("id","quantity","name")

There are several predefined events you can use

The ViewContent event is a type of event that is commonly tracked to monitor user behavior on your app. This event is typically triggered when a user views a specific piece of content, such as a product, article, or video. By tracking ViewContent events, developers can gain insights into what content users are engaging with most and optimize their content strategy accordingly. The ViewContent event is one of many events that can be tracked by event tracking platforms, and is an important component of user analysis and app optimization.

ConvertedInSdk().viewContentEvent("Currency","Total","products")
//where eventName is "ViewContent"

The PageView event is a type of event that is commonly tracked to monitor user behavior on your app. This event is triggered when a user views a page or screen within the app. By tracking PageView events, developers can gain insights into how users navigate through their app and optimize the user experience accordingly. The PageView event is one of the most basic and commonly tracked events in event tracking, and is an important component of user analysis and app optimization.

ConvertedInSdk().pageViewEvent("Currency","Total","products")
//where eventName is "PageView"

The AddToCart event is a type of event that is commonly tracked to monitor user behavior on an e-commerce app. This event is triggered when a user adds a product to their shopping cart. By tracking AddToCart events, developers can gain insights into which products are most popular and optimize their product offering and pricing accordingly. The AddToCart event is often paired with other e-commerce events such as Purchase or Checkout events, and is an important component of user analysis and e-commerce optimization.

ConvertedInSdk().addToCartEvent("Currency","Total","products")
//where eventName is "AddToCart"

The InitiateCheckout event is a type of event that is commonly tracked to monitor user behavior during the checkout process on an e-commerce app. This event is triggered when a user begins the process of checking out and entering their payment and shipping information. By tracking InitiateCheckout events, developers can gain insights into how users interact with the checkout process and identify areas for improvement to increase conversion rates. The InitiateCheckout event is often paired with other e-commerce events such as AddToCart or Purchase events, and is an important component of user analysis and e-commerce optimization.

ConvertedInSdk().initiateCheckoutEvent("Currency","Total","products")
//where eventName is "InitiateCheckout"

The Purchase event is a type of event that is commonly tracked to monitor user behavior on an e-commerce app. This event is triggered when a user completes a purchase and successfully makes a payment for a product or service. By tracking Purchase events, developers can gain insights into which products are most popular and identify patterns in user behavior to optimize the checkout process and increase sales. The Purchase event is often paired with other e-commerce events such as AddToCart or InitiateCheckout events, and is an important component of user analysis and e-commerce optimization.

ConvertedInSdk().purchaseEvent("Currency","Total","products")
//where eventName is "Purchase"

Step 5: ​Initialize push notifications and configure it.

To use Convertedin SDK’s push notifications, you need to integrate with firebase notifications

Integrating your Android app with Firebase Notifications allows you to send push notifications to your app users. Here are the steps to integrate your Android app to Firebase Notifications:

  1. Create a Firebase project: If you haven't already, create a Firebase project in the Firebase console and add your Android app to it.

  2. Add the Firebase SDK to your app: Add the Firebase SDK to your app by following the instructions provided by Firebase. This involves adding the necessary dependencies to your app's Gradle files and downloading a google-services.json file from the Firebase console and adding it to your app.

  3. Set up Firebase Cloud Messaging: Firebase Cloud Messaging (FCM) is the service that powers Firebase Notifications. Follow the instructions provided by Firebase to set up FCM for your Android app.

  4. Add Firebase messaging to your app: To receive Firebase Notifications in your app, you need to add Firebase Messaging to your app. This involves creating a FirebaseMessagingService and registering it in your app's AndroidManifest.xml file.

  5. Handle incoming messages: Once you have set up Firebase Messaging in your app, you can receive incoming messages in your FirebaseMessagingService. You can then handle the message data and display a notification to the user.

  6. Test your integration: Finally, test your Firebase Notifications integration by sending a test notification from the Firebase console or using a third-party tool like Postman.

By following these steps, you can integrate your Android app with Firebase Notifications and start sending push notifications to your app users.

After Integrating with firebase successfully, call this method on the SDK to send the firebase token to start getting notifications from your dashboard

ConvertedInSdk().saveDeviceToken("token")
//where token is firebase token

⚠️ Important Note: Each Time firebase token is updated you must call saveDeviceToken method to save the new firebase token

If user logged out or you want user to stop getting notifications from our side, you can call this method

ConvertedInSdk().deleteDeviceToken()

Step 1: ​Downloading and importing the SDK.

Download the SDK from here and follow the steps

  1. Open your Android Studio project.

  2. Click on the "File" menu and select "New" > "Import Module".

  3. In the "Import Module" dialog box, Browse and select the module file you want to import, then click "Finish".

  4. In the "Project" view, you should now see the imported module as a sub-project within your main project.

Step 2: ​Adding the dependency to your Gradle files.

dependencies {
  implementation project(path: ':PixelSDK')
  }

proguard-rules

# Keep all classes and members in the convertedin.pixel.pixelsdk package
-keep class convertedin.pixel.pixelsdk.** { *; }

# Prevent proguard from stripping interface information from TypeAdapter, TypeAdapterFactory,
# JsonSerializer, JsonDeserializer instances (so they can be used in @JsonAdapter)
-keep class * extends com.google.gson.TypeAdapter
-keep class * implements com.google.gson.TypeAdapterFactory
-keep class * implements com.google.gson.JsonSerializer
-keep class * implements com.google.gson.JsonDeserializer

-keepattributes Signature
-keepattributes *Annotation*

# Prevent R8 from leaving Data object members always null
-keepclassmembers,allowobfuscation class * {
  @com.google.gson.annotations.SerializedName <fields>;
}

# Retain generic signatures of TypeToken and its subclasses with R8 version 3.0 and higher.
-keep,allowobfuscation,allowshrinking class com.google.gson.reflect.TypeToken
-keep,allowobfuscation,allowshrinking class * extends com.google.gson.reflect.TypeToken
-keep,allowobfuscation,allowshrinking class * implements java.lang.reflect.Type
-keep class com.google.common.reflect.TypeToken { *; }


# Gson specific classes
-dontwarn sun.misc.**
-keep class com.google.gson.stream.** { *; }

-keep class java.util.HashMap { *; }

# Keep generic signature of Call, Response (R8 full mode strips signatures from non-kept items).
 -keep,allowobfuscation,allowshrinking interface retrofit2.Call
 -keep,allowobfuscation,allowshrinking class retrofit2.Response

# Keep classes and members that are used by RxJava
-keep class io.reactivex.** { *; }
-keep class * extends io.reactivex.** { *; }
-keep class * implements io.reactivex.** { *; }

# Keep methods that are used by RxJava subscribers
-keepclassmembers class * {
    void onSubscribe(io.reactivex.disposables.Disposable);
    void onNext(*);
    void onError(java.lang.Throwable);
    void onComplete();
}

Last updated