Mobile Development 11 min read

Implementing Mobile Data Collection and Analytics with Countly: Architecture, Customization, and Insights

This article outlines how to design and implement a comprehensive mobile data collection and analysis system using the open‑source Countly platform, covering background requirements, solution selection, architecture, customizations for client, server and dashboard, SDK integration for Android and H5, and practical data mining insights.

Zhengtong Technical Team
Zhengtong Technical Team
Zhengtong Technical Team
Implementing Mobile Data Collection and Analytics with Countly: Architecture, Customization, and Insights

The document begins by identifying key business questions about user numbers, daily active users, upgrade success rates, device compatibility, and early fault detection, emphasizing the need for systematic data collection rather than manual, incomplete surveys.

It introduces the concept of "埋点" (event tracking) as the technical means to capture user behavior, device information, and app events, which are then uploaded to a server for aggregation and analysis.

After evaluating several third‑party analytics services (Umeng+, Tencent MTA, Baidu MTJ, Sensors, Firebase, GrowingIO, Fabric) and the open‑source Countly framework, Countly was chosen for its self‑hosted deployment, crash‑log analysis, open‑source customizability, and avoidance of data lock‑in.

Countly is described as a real‑time, open‑source mobile analytics solution consisting of a Node.js server, an Express‑jQuery‑Handlebars dashboard, and client SDKs for Android, iOS, Web, Cordova, ReactNative, Flutter, etc., with MongoDB as the database.

The overall architecture deploys Countly‑server and Countly‑dashboard on an external server, assigns a unique appKey per project, and visualizes each project's data separately on the dashboard.

To automate project onboarding, customizations were made:

Client: encrypt the server URL to generate an appKey and include it in APK uploads.

Countly‑server: if an incoming appKey has no matching application, automatically create a new app named "NewProject+timestamp".

Countly‑dashboard: decrypt the appKey to retrieve the server URL, map it to a project name, and display the data.

Android SDK integration example:

android {
    dependencies {
        compile 'cn.com.egova.mobile.3rd:countly:0.1.0'
    }
}

Data upload code registers activity lifecycle callbacks to record page entry/exit and defines custom events such as plugin opening and app updates:

application.registerActivityLifecycleCallbacks(new Application.ActivityLifecycleCallbacks() {
    @Override
    public void onActivityStarted(Activity activity) {
        // record page entry
    }
    @Override
    public void onActivityStopped(Activity activity) {
        // record page exit
    }
    // ...
});

public class CountlyCustomEvent {
    public static class OpenPlugin {
        public static void record(String pluginName) { /* ... */ }
    }
    public static class UpdateApp {
        public static void record(boolean success, String failedReason) { /* ... */ }
    }
    // ...
}

H5 SDK integration example (package.json):

{
  "dependencies": {
    "countly-sdk-web": "^19.8.0"
  }
}

Data upload in a Vue router hook and custom event definition:

options.router.beforeEach((to, from, next) => {
    // record page navigation
    // ...
    next();
});

countly.prototype = {
    customEvent: {
        request: {
            record: ({method, success, code, message, duration}) => {
                // ...
            }
        }
    }
};

The article then demonstrates how collected data solves the initial questions: generating nationwide user heatmaps, calculating daily active users and growth rates, measuring APK upgrade success and failure reasons, assessing Android version distribution for compatibility decisions, and setting up fault monitoring with pre‑emptive alerts.

Finally, it emphasizes that data‑driven insights enable continuous product improvement, targeted feature development, and broader business value beyond the four showcased scenarios, with Countly’s open‑source nature offering further extensibility.

data collectionData Miningmobile analyticsAndroid SDKCountlyH5 SDK
Zhengtong Technical Team
Written by

Zhengtong Technical Team

How do 700+ nationwide projects deliver quality service? What inspiring stories lie behind dozens of product lines? Where is the efficient solution for tens of thousands of customer needs each year? This is Zhengtong Digital's technical practice sharing—a bridge connecting engineers and customers!

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.