Mobiqo SDK for Capacitor apps - Mobile analytics and user tracking
npm install mobiqo-capacitor⚠️ THIS PLUGIN HAS TO BE USED ALONG WITH THE ANALYTICS SERVICE MOBIQO ⚠️
👉 CREATE AN ACCOUNT HERE: https://getmobiqo.com?utm_source=npm
---
A Capacitor plugin for integrating Mobiqo analytics into your mobile applications.
``bash`
npm install mobiqo-capacitor
`typescript`
import Mobiqo from 'mobiqo-capacitor';
import { MobiqoEvent } from 'mobiqo-capacitor';
`typescript
const mobiqo = new Mobiqo();
// Initialize with your Mobiqo API key
await mobiqo.init({ mobiqoKey: 'your-mobiqo-api-key' });
`
`typescript
// With additional data (optional)
await mobiqo.syncUser({
revenue_cat_user_id: 'user-123',
include_advanced_analysis: false,
additional_data: {
user_id: 'user-123',
user_name: 'John Doe',
user_email: 'user@example.com',
referrer: 'google'
}
});
// Without additional data
await mobiqo.syncUser({
revenue_cat_user_id: 'user-123'
});
`
`typescript
// Track an event with additional data (optional)
await mobiqo.trackEvent(
'button_clicked',
MobiqoEvent.CLICK,
{
button_name: 'subscribe',
screen: 'home'
}
);
// Track an event without additional data
await mobiqo.trackEvent('screen_opened', MobiqoEvent.SCREEN_VIEW);
`
`typescript`
// Update user information without creating a new session
await mobiqo.updateUser({
revenue_cat_user_id: 'user-123',
additional_data: {
user_id: 'user-123',
user_name: 'John Doe Updated',
user_email: 'newemail@example.com',
referrer: 'facebook'
}
});
`typescript`
const userInfo = await mobiqo.getUserInfo({
revenue_cat_user_id: 'user-123',
include_advanced_analysis: true
});
The SDK automatically sends heartbeats every 20 seconds after user sync to maintain session tracking. No manual intervention is required.
#### init(options)options.mobiqoKey
Initialize the Mobiqo service with your API key.
- (string): Your Mobiqo API key
#### syncUser(options)options.revenue_cat_user_id
Sync user data with Mobiqo and start a session.
- (string): RevenueCat user IDoptions.include_advanced_analysis
- (boolean, optional): whether or not to include advanced analysis in the response (to get the purchase probability and other data, but the request will take more time)options.additional_data
- (AdditionalData, optional): Additional user data (user_id, user_name, user_email, referrer)
#### updateUser(options)options.revenue_cat_user_id
Update user information without creating a new session.
- (string): RevenueCat user IDoptions.additional_data
- (AdditionalData, optional): Additional user data to update (user_id, user_name, user_email, referrer)
#### getUserInfo(options)options.revenue_cat_user_id
Retrieve user information from Mobiqo.
- (string): RevenueCat user IDoptions.include_advanced_analysis
- (boolean): whether or not to include advanced analysis in the response (to get the purchase probability and other data, but the request will take more time)
#### trackEvent(event, eventType, additionalData?)event
Track custom events.
- (string): Event nameeventType
- (MobiqoEvent): Event type from the MobiqoEvent enumadditionalData
- (Record
`typescript`
enum MobiqoEvent {
CLICK = 'click',
ACTION = 'action',
SCREEN_VIEW = 'screen_view',
PAYWALL_VIEW = 'paywall_view',
PAYWALL_DISMISS = 'paywall_dismiss',
PURCHASE_ATTEMPT = 'purchase_attempt',
PURCHASE_SUCCESS = 'purchase_success',
PURCHASE_FAILED = 'purchase_failed',
FORM_SUBMIT = 'form_submit',
NAVIGATION = 'navigation',
ERROR = 'error',
CUSTOM = 'custom'
}
#### SyncUserResponse`typescript`
interface SyncUserResponse {
isNewUser: boolean;
appUser: AppUser;
statistics: Statistics;
}
#### GetUserInfoResponse`typescript`
interface GetUserInfoResponse {
appUser: AppUser;
statistics: Statistics;
}
#### AppUser`typescript`
interface AppUser {
id: string;
project_id: string;
revenue_cat_user_id?: string;
mobiqo_username: string;
os: 'ios' | 'android';
os_version: string;
app_version: string;
country?: string;
language?: string;
first_seen_at: string;
last_seen_at: string;
active_entitlements: string[];
}
#### Statistics`typescript`
interface Statistics {
purchasing_power_parity: number;
purchase_intent: number;
avg_arpu: number;
avg_arppu: number;
avg_ltv: number;
}
#### AdditionalData`typescript``
interface AdditionalData {
user_id?: string;
user_name?: string;
user_email?: string;
referrer?: string;
}
- Capacitor 3.0+
- TypeScript 4.0+
MIT
For support and questions, please contact the Mobiqo team.