SDKs overview

Countly provides a range of Software Development Kits (SDKs) designed to facilitate the integration of its analytics platform into various applications and services. These SDKs enable developers to collect data on user behavior, application performance, and engagement across mobile, web, and server-side environments. Countly's SDKs support features such as session tracking, event logging, crash reporting, push notifications, and A/B testing, which contribute to comprehensive product usage insights Countly API Reference v1.1.

The SDKs are structured to allow for both basic analytics implementation and advanced customization, offering control over data collection and processing. Countly emphasizes data privacy, providing options for self-hosting and granular control over data points collected, aligning with privacy regulations such as GDPR Countly Homepage Privacy Policy.

Official SDKs by language

Countly maintains official SDKs for a broad spectrum of programming languages and platforms, ensuring compatibility with common development ecosystems. These SDKs are developed and supported by Countly, offering direct integration with the Countly server for data transmission and analysis. The table below lists some of the primary official SDKs:

Language/Platform Package/Module Typical Installation Maturity
Android countly-sdk-android implementation 'ly.count.android:sdk:21.11.0' Stable
iOS (Swift/Objective-C) Countly pod 'Countly' (CocoaPods) Stable
JavaScript countly-sdk-web npm install countly-sdk-web Stable
React Native countly-sdk-react-native npm install countly-sdk-react-native Stable
Flutter countly_flutter flutter pub add countly_flutter Stable
Unity CountlyGameAnalytics Unity Package import Stable
Node.js countly-sdk-nodejs npm install countly-sdk-nodejs Stable
Python countly-sdk-python pip install countly-sdk-python Stable
PHP (Official PHP library) Composer: require countly/countly-sdk-php Stable
Ruby countly-sdk-ruby gem install countly-sdk-ruby Stable
.NET Countly.NET.SDK NuGet: Install-Package Countly.NET.SDK Stable
Java (server-side) countly-java-sdk Maven/Gradle dependency Stable
Go (Official Go library) go get github.com/Countly/go-sdk Stable
C++ (Official C++ library) Manual compilation or package manager Beta/Stable

Installation

Installation methods vary depending on the platform and programming language. Below are common installation approaches for popular Countly SDKs:

Android SDK

For Android applications, integrate the Countly SDK by adding the dependency to your app's build.gradle file:

dependencies {
    implementation 'ly.count.android:sdk:21.11.0' // Use current version
}

Then, initialize the SDK in your application's onCreate method, as detailed in the Countly Android SDK documentation.

iOS SDK (Swift/Objective-C)

Using CocoaPods, add the following to your Podfile:

platform :ios, '10.0'
target 'YourApp' do
  use_frameworks!
  pod 'Countly'
end

Then run pod install. For manual installation or Swift Package Manager, refer to the Countly iOS SDK setup guide.

JavaScript SDK

For web applications, install via npm:

npm install countly-sdk-web

Alternatively, include the SDK directly via a script tag:

<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/countly-sdk-web@latest/lib/countly.min.js"></script>

Initialization and usage examples are available in the Countly JavaScript SDK documentation.

Quickstart example

This example demonstrates a basic initialization and event logging using the Countly JavaScript SDK. Similar patterns apply across other SDKs, with syntax adaptations for each language. For a complete guide, consult the Countly SDK reference documentation.

// For web applications using the JavaScript SDK

// 1. Initialize Countly
// Replace 'YOUR_APP_KEY' with your actual application key from Countly dashboard
// Replace 'https://YOUR_COUNTLY_SERVER' with your Countly server URL
Countly.init({
    app_key: 'YOUR_APP_KEY',
    url: 'https://YOUR_COUNTLY_SERVER',
    // Optional: Enable debug mode to see console logs
    debug: true,
    // Optional: Set a customer user ID
    device_id: 'unique_user_id_123'
});

// 2. Start a session
Countly.q.push(['track_sessions']);

// 3. Track a custom event
// Example: User clicked a 'Buy Now' button
Countly.q.push(['track_event', {
    key: 'buy_button_click',
    count: 1,
    segmentation: {
        product_id: 'P12345',
        category: 'Electronics',
        price: 99.99
    }
}]);

// Example: User viewed a product page
Countly.q.push(['track_event', {
    key: 'product_page_view',
    segmentation: {
        page_name: 'Product Details',
        product_sku: 'SKU789'
    }
}]);

// 4. Track user properties (optional)
// Example: Update user's name and email
Countly.q.push(['user_details', {
    'name': 'John Doe',
    'email': '[email protected]',
    'gender': 'M',
    'organization': 'Acme Corp',
    'age': 30
}]);

// 5. Track page views for single-page applications (optional, not needed for traditional page loads)
// Call this whenever the route changes in your SPA
function trackPageView(pageName) {
    Countly.q.push(['track_pageview', pageName]);
}

// Example usage within an SPA framework (e.g., React Router, Vue Router)
// router.afterEach((to, from) => {
//   trackPageView(to.path);
// });

This snippet initializes the Countly SDK, starts a user session, tracks two custom events with segmentation data, and updates user details. The Countly.q.push array is used to queue commands to ensure they are processed even if the SDK isn't fully loaded yet.

Community libraries

While Countly provides a comprehensive set of official SDKs, the open-source nature of some of its components encourages community contributions. These community-developed libraries and wrappers can extend Countly's reach to additional platforms or provide alternative integration patterns. While not officially supported by Countly, they often fill specific niches or offer bespoke functionalities.

Developers contributing to or using community libraries should verify their compatibility, maintenance status, and adherence to Countly's data collection principles. For instance, specific integrations with less common frameworks or server-side languages might emerge from the community. A general overview of the open-source ecosystem relevant to analytics SDKs can be found in resources like the Cloud Native Computing Foundation blog on open source data analytics, which highlights the broader trend of community-driven development in analytics.

Users are encouraged to consult Countly's official documentation for the most up-to-date and officially supported integration methods Countly Support Documentation. For community-driven projects, GitHub and other open-source repositories are typically the primary sources for discovery and contributions.