Integrating third party analytics SDK using Nias module in Android

Android Development Feb 21, 2022

Analytics SDK provide data insights to improve user experience and engagement. Integration of third party SDKs and tracking events come with development effort. This method will help you to reduce development effort and avoid third party code inside application.


Create a separate module which accelerate integration of third party analytics SDK(s) without increase in APK size. You can avoid third party code inside application.

What is Analytics

Analytics is the process of discovering, interpreting, and communicating significant patterns in data. In a simple way, analytics help us to see insights and meaningful data. Business analytics focuses on using insights derived from data to make more informed decisions that will help organisations increase sales, reduce costs, and make other business improvements.

App analytics is used to track user interaction with your app to improve user experience and business.

There are the following benefits of app analytics

Drive ROI

App analytics help us to understand user behaviour to improve user experience and retention. Retention is a key factor to increase the revenue of a business.

Gather Accurate Data

App analytics help us to gain insight of customer data about use patterns and feedback. One can understand the pattern listen to user requirements and serve them better.

Customer-Focused Marketing

App analytics help us to send personalise messages to convert them into higher stage of life cycle. Customer-targeted push messages delivered to specific people can make your app open rates double in a short amount of time, and can convert up to three times better than generic push messages.

Track Marketing Goals

App analytics gives you a whole new set of customer data to learn from. Now more than ever before, app marketers can gain insight around individuals and small groups of customers completing specific, directed tasks within the app, and the possibility to capitalize on this knowledge is endless.

Data-Driven Insights

App analytics provides real-time data to learn why, when and where your customers dump your app which helps marketers to meet the problem and provide new offers to win them back.

App Analytics Integration Challenges

  1. App analytics SDK can be replace by another third party SDK due to feature or cost effective. If you have huge event so remove a specific SDK and adding a new one will require a huge dev effort.
  2. After using a specific analytics SDK marketing team realize to integrate another SDK. It would be a good amount of development effort to replicate all event to new SDK.
  3. If any other SDK provides some more effective features which would help us drive our app better, we might have to plan to integrate the new SDK and safely delete the old one.
  4. If we come across any other third party company which would provide more data insights and the marketing team finds it easier to take insights from the data recorded, we will have to change the SDK.

We have already discussed common issues while integrating app analytics in application. Now we are going to discuss about architecture that we developed in Halodoc to take care of these common issues with less development effort.

Nias Module

Nias module is a component that provide application to register app analytics plugins, update user properties and track events. It will contain all third party SDK code separate from application. So, there is no code change in application while removing or adding third party SDK.

Nias module provide following feature to application.

  1. Application can register one or multiple App Analytics SDK using AnalyticsPlugin
  2. One can define EventFilter according to use.
  3. Initialize all registered AnalyticsSDK
  4. Ensure single source of truth to update same user properties to all register SDK.
  5. Provide a function to track events to all register Analytics SDK.
  6. If any app using multiple SDK so we are able to filter event with respect to specific SDK.

Component Diagram

Component Diagram of Nias

In above component diagram we can see that Nias module can have one or more AnalyticsPlugin depends on the number of analytics SDK we are using.

AnalyticsPlugin will wrap all third party SDK code and help provide way to update user properties and send events to respective SDK.

Sequence Diagram:

Sequence Diagram

Application can perform following 3 type of action using Nias module.

  • Application needs to initialise all the SDK that is register with it. Following code snippet will help you to understand register analytics SDK using AnalyticsPlugin.
  • Update user properties in each and every analytics SDK that are registered in Nias module.
  • Following code snippet is used to send user events to all register SDK from application.

New SDK Integration :

  1. Add latest version of analytic SDK dependencies into Nias module.
  2. Create SDK plugin and Implement and followings method that is required to initialise and communicate with SDK.
    init(Application application, String pluginKey, EventFilter eventFilter) is required to setup and initialise analytic SDK.
    isEventToBeTracked(Event event) is used to filter event using its type.
    trackEvent(@NonNull Event event) is used to track an event.
  3. After implementation of required functionality add latest dependency into application and register  plugin with Nias that we have already discussed.

Conclusion :

With the adaption of Nias module, it is very easy to add or remove any third party SDK with less effort and and without any code changes in application. This would mean that all changes will take place into Nias Module.

It will also save development effort to send events to all register SDK as well as increase the developer efficiency.

Join us

Scalability, reliability and maintainability are the three pillars that govern what we build at Halodoc Tech. We are actively looking for engineers at all levels and  if solving hard problems with challenging requirements is your forte, please reach out to us with your resumé at

About Halodoc

Halodoc is the number 1 all around Healthcare application in Indonesia. Our mission is to simplify and bring quality healthcare across Indonesia, from Sabang to Merauke. We connect 20,000+ doctors with patients in need through our Tele-consultation service. We partner with 3500+ pharmacies in 100+ cities to bring medicine to your doorstep. We've also partnered with Indonesia's largest lab provider to provide lab home services, and to top it off we have recently launched a premium appointment service that partners with 500+ hospitals that allow patients to book a doctor appointment inside our application. We are extremely fortunate to be trusted by our investors, such as the Bill & Melinda Gates Foundation, Singtel, UOB Ventures, Allianz, GoJek, Astra, Temasek and many more. We recently closed our Series C round and In total have raised around USD$180 million for our mission. Our team works tirelessly to make sure that we create the best healthcare solution personalised for all of our patient's needs, and are continuously on a path to simplify healthcare for Indonesia.