Integration Overview
Countly integrates with development tools, data platforms, and notification services to fit into your existing workflow.
Mobile Development Platforms
iOS
Native Swift/Objective-C SDK:
// AppDelegate.swift
import Countly
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
let config = CountlyConfig()
config.appKey = "YOUR_APP_KEY"
config.host = "https://your-countly-server.com"
config.features = [.sessions, .events, .crashReporting, .pushNotifications]
Countly.sharedInstance().start(with: config)
return true
}
Android
Native Kotlin/Java SDK:
// Application class
class MyApp : Application() {
override fun onCreate() {
super.onCreate()
val config = CountlyConfig(this, "YOUR_APP_KEY", "https://your-countly-server.com")
.setLoggingEnabled(true)
.enableCrashReporting()
Countly.sharedInstance().init(config)
}
}
React Native
import Countly from 'countly-sdk-react-native-bridge';
Countly.init({
appKey: 'YOUR_APP_KEY',
serverUrl: 'https://your-countly-server.com',
deviceId: Countly.TemporaryDeviceID,
features: [
Countly.Feature.SESSIONS,
Countly.Feature.EVENTS,
Countly.Feature.CRASHES,
Countly.Feature.PUSH
]
});
Flutter
import 'package:countly_flutter/countly_flutter.dart';
void initCountly() async {
CountlyConfig config = CountlyConfig(
'https://your-countly-server.com',
'YOUR_APP_KEY'
);
config.setLoggingEnabled(true);
await Countly.initWithConfig(config);
}
Web Integration
JavaScript SDK
<script type="text/javascript">
var Countly = Countly || {};
Countly.app_key = 'YOUR_APP_KEY';
Countly.url = 'https://your-countly-server.com';
(function() {
var cly = document.createElement('script');
cly.type = 'text/javascript';
cly.async = true;
cly.src = 'https://your-countly-server.com/sdk/web/countly.min.js';
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(cly, s);
})();
</script>
React
import Countly from 'countly-sdk-web';
Countly.init({
app_key: 'YOUR_APP_KEY',
url: 'https://your-countly-server.com',
session_update: 60,
use_session_cookie: true
});
Countly.track_sessions();
Countly.track_pageview();
Vue.js
// main.js
import Countly from 'countly-sdk-web';
Countly.init({
app_key: 'YOUR_APP_KEY',
url: 'https://your-countly-server.com'
});
// router/index.js
router.afterEach((to) => {
Countly.track_pageview(to.path);
});
Next.js
// pages/_app.js
import { useEffect } from 'react';
import { useRouter } from 'next/router';
import Countly from 'countly-sdk-web';
function MyApp({ Component, pageProps }) {
const router = useRouter();
useEffect(() => {
Countly.init({
app_key: 'YOUR_APP_KEY',
url: 'https://your-countly-server.com'
});
Countly.track_sessions();
const handleRouteChange = (url) => {
Countly.track_pageview(url);
};
router.events.on('routeChangeComplete', handleRouteChange);
return () => router.events.off('routeChangeComplete', handleRouteChange);
}, []);
return <Component {...pageProps} />;
}
Data Export & Warehousing
REST API
Export data programmatically:
# Get event data
curl -X GET "https://your-countly-server.com/o?api_key=YOUR_API_KEY&app_id=YOUR_APP_ID&method=events"
# Get session data
curl -X GET "https://your-countly-server.com/o?api_key=YOUR_API_KEY&app_id=YOUR_APP_ID&method=sessions"
Data Export Plugin
For large-scale exports:
- Install the Data Export plugin
- Configure export destinations:
- Amazon S3
- Google Cloud Storage
- Custom HTTP endpoint
- Set export schedule and format
Custom Webhooks
Forward events to external systems:
// Countly Plugin: Forward events
module.exports = {
onEvent: function(event, device_id, app_id) {
// Forward to your webhook
fetch('https://your-webhook.com/countly', {
method: 'POST',
body: JSON.stringify(event)
});
}
};
Push Notification Services
Firebase Cloud Messaging (Android)
// Configure FCM
val config = CountlyConfig(this, appKey, serverUrl)
.setPushIntentAddMetadata(true)
.setRemoteConfigAutomaticDownload(true)
// Handle FCM token
FirebaseMessaging.getInstance().token.addOnCompleteListener { task ->
val token = task.result
Countly.sharedInstance().push().onTokenRefresh(token)
}
Apple Push Notification service (iOS)
// Configure APNs
config.pushTestMode = .development // or .production
config.sendPushTokenAlways = true
// Handle token
func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
Countly.sharedInstance().didRegisterForRemoteNotifications(withDeviceToken: deviceToken)
}
Authentication Integrations
LDAP/Active Directory
Enterprise Edition supports LDAP:
// config.js
{
ldap: {
enabled: true,
server: 'ldap://your-ldap-server.com',
baseDN: 'dc=company,dc=com',
bindDN: 'cn=admin,dc=company,dc=com',
bindPassword: 'password'
}
}
SSO/SAML
Configure SAML 2.0 integration:
- Go to Management → Authentication
- Enable SAML authentication
- Configure IdP settings:
- Entity ID
- SSO URL
- Certificate
Development Tools
Segment Integration
Send data from Segment to Countly:
// Segment Destination Function
exports.handler = async (event) => {
await fetch('https://your-countly-server.com/i', {
method: 'POST',
body: JSON.stringify({
app_key: 'YOUR_APP_KEY',
device_id: event.userId,
events: [{
key: event.event,
segmentation: event.properties
}]
})
});
};
Slack Notifications
Receive alerts in Slack:
- Install the Slack plugin
- Configure webhook URL
- Set up alert conditions:
Plugin Architecture
Available Plugins
Countly's plugin system extends functionality:
- Crash Analytics: Detailed crash reporting
- Push Notifications: Multi-platform messaging
- Surveys: In-app feedback collection
- A/B Testing: Experiment management
- Funnels: Conversion analysis
- Cohorts: User segmentation
- Retention: User stickiness analysis
- Revenue: Monetization tracking
Installing Plugins
For self-hosted installations:
# Install a plugin
cd /path/to/countly
countly plugin enable crashes
# Restart Countly
countly restart
Troubleshooting Integrations
SDK Not Sending Data
- Verify server URL and app key
- Check network connectivity
- Enable SDK logging for diagnostics
- Confirm server is accepting connections
Push Notifications Not Arriving
- Verify push credentials (FCM/APNs)
- Check device token registration
- Test with development certificates first
- Review push plugin configuration
Data Not Appearing
- Check data retention settings
- Verify event format is correct
- Confirm app ID matches dashboard
- Review API key permissions