Skip to main content

User Profiles - API Documentation

Enterprise Only
This feature is available exclusively in Countly Enterprise.

Overview

The User Profiles feature provides comprehensive user-level analytics and detailed user profile management for Countly Enterprise. It enables access to individual user timelines, engagement metrics, session data, event tracking, and custom user properties—all critical for understanding user behavior at the finest granularity.

This feature extends Countly's drill functionality to expose user-specific analytics endpoints, allowing administrators and analysts to drill down from aggregated data to individual user records with full event history, session information, and custom attributes.

Key Features

  • User List & Search: Query lists of users with filtering, sorting, and pagination
  • User Details: Access complete user profiles including engagement scores and custom properties
  • User Timeline: View chronological event and session history for individual users
  • User Graph Analytics: Time-series graphs of user engagement, sessions, and event frequency
  • Session Breakdown: Review detailed session information per user with duration, location, device info
  • Event Timeline: Complete event history per user with calculated properties and custom dimensions
  • Engagement Scoring: Automatic engagement metrics including session count, days active, and activity frequency
  • Custom Properties: Store and query unlimited custom user properties with expiration policies
  • User Search: Full-text search across user names, emails, usernames, and device IDs
  • Batch Processing: Server-side batch processing for large user queries with configurable limits

Configuration Settings

SettingDefaultTypeDescriptionEnvironment Variable
custom_set_limit50NumberMaximum number of custom properties per userCOUNTLY_CONFIG_PLUGINUSERS_CUSTOMSETLIMIT
custom_prop_limit20NumberIndividual property value limit for custom propertiesCOUNTLY_CONFIG_PLUGINUSERS_CUSTOMPROPLIMIT
show_notes_in_listtrueBooleanDisplay user notes in user list viewCOUNTLY_CONFIG_PLUGINUSERS_SHOWNOTESINLIST
sampling_threshold100000NumberUser count threshold for enabling sampling in queriesCOUNTLY_CONFIG_PLUGINUSERS_SAMPLINGTHRESHOLD
batch_size100NumberNumber of users processed per batch in background jobsCOUNTLY_CONFIG_PLUGINUSERS_BATCHSIZE
batch_cooldown10NumberMilliseconds between batch processing cyclesCOUNTLY_CONFIG_PLUGINUSERS_BATCHCOOLDOWN
app_user_jobtrueBooleanEnable background jobs for user aggregation and statsCOUNTLY_CONFIG_PLUGINUSERS_APPUSERJOB
engagement_scoretrueBooleanCalculate and track engagement score metrics per userCOUNTLY_CONFIG_PLUGINUSERS_ENGAGEMENTSCORE

Authentication

All user analytics endpoints require standard Countly authentication:

MethodRequiredDescription
HTTP MethodGET or POSTBoth methods accepted interchangeably
API KeyYesAdmin or analyst API key with user read permissions
App IDYesApplication ID for which to retrieve user data

Endpoints

Internal Events (Not Public Requests)

These endpoints are internal lifecycle events dispatched by core and should not be treated as public API requests:

  • POST /i/apps/create
  • POST /i/apps/reset
  • POST /i/apps/clear_all

Database Collections

The User Profiles feature stores and queries data from these MongoDB collections:

CollectionPurposeFields
countly.app_users{appid}User profiles with engagement metrics and custom properties_id, uid, name, email, custom, engagement_score, sc (session count), ls (last session), tsd (total session duration)
countly_drill.drill_eventsEvent records for all users including custom propertiests, e (event name), u (user ID), c (custom properties), cc (country), cty (city), did (device ID), p (platform)
countly_drill.drill_metaEvent and property metadata including custom property definitions_id, e (event names), s (segment names), custom (custom property definitions)
countly.appsApplication configurations including user custom property settings_id (app_id), ovveridden_types (custom property type overrides)

Collection Indexes

The User feature automatically creates the following indexes on countly.app_users{appid}:

  • uid: User ID lookup
  • name: User name search
  • {hasInfo: 1, name: 1}: Efficient filtration by profile completion
  • sc: Session count aggregations
  • {hasInfo: 1, sc: 1}: Combined profile and session filtering
  • {hasInfo: 1, lac: -1}: Last activity tracking
  • tsd: Total session duration sorting
  • {hasInfo: 1, tsd: 1}: Duration-based queries
  • {name: "text", email: "text", username: "text", did: "text", uid: "text"}: Full-text search index
  • {"chr.$**": 1}: Custom property wildcard index for flexible custom property queries
  • {hasInfo: 1, ls: -1}: Last session recency sorting

User Profile Fields

Core Fields

FieldTypeDescriptionExample
_idStringUser identifier (device hash at first, can be changed by SDK)abc1234567890def1234567890abc123
uidNumberNumeric user identifier12345
nameStringUser's full nameJohn Doe
emailStringUser's email addressjohn@example.com
usernameStringUser login usernamejohndoe
phoneStringUser's phone number+1-555-123-4567
organizationStringUser's organization/companyAcme Corp
pictureStringURL path to user's profile picture/userimages/123456789/{uid}.png

Demographic Fields

FieldTypeDescriptionExample
byearNumberBirth year1991
ageNumberCalculated age (current year - birth year)33
genderStringGender: M (male), F (female), or emptyM
ccStringCountry code (2-letter ISO)US
ctyStringCity nameNew York

Engagement Metrics

FieldTypeDescriptionExample
scNumberSession count (total number of sessions)42
eNumberEvent count (total events recorded)1245
dNumberDays active (distinct days with activity)38
lsNumberLast session timestamp (Unix epoch)1707619200
tsdNumberTotal session duration (milliseconds)126540
dsNumberDevice switching count5
engagement_scoreNumberCalculated engagement metric (0-100+)75
engagementObjectPer-day engagement breakdown (if enabled){"2024-01-15": {"sc": 2, "sd": 1200}}

Technical Fields

FieldTypeDescriptionExample
didStringDevice IDdevice123ABC
uid_seqNumberSequential user ID1000
hasInfoBooleanWhether user has any information settrue
customMetaObjectMetadata for custom properties (last updated times){"property_name": {"last_updated": 1707619200}}

Custom Properties

FieldTypeDescriptionExample
customObjectUser-defined custom properties (up to custom_set_limit properties){"subscription_tier": "premium", "ltv": 250.50}

Use Cases

Use Case 1: High-Value Customer Analysis

Identify and analyze high-value customers with engagement metrics:

GET /o?api_key={API_KEY}&app_id={APP_ID}&method=user_details
&query={"custom.ltv":{$gte:1000}}
&sort=tsd&order=-1
&iDisplayLength=100
&calculate=graph
&period=30days

Purpose: Find top users by lifetime value and engagement, track their session trends.

Use Case 2: User Churn Detection

Identify users at risk of churning based on inactivity:

GET /o?api_key={API_KEY}&app_id={APP_ID}&method=user_details
&query={"ls":{$lt:{currentTimestamp - 30days}},
"sc":{$gte:10}}
&sort=ls&order=1
&calculate=sessions

Purpose: Find previously active users who haven't returned in 30 days; retrieve their last sessions.

Use Case 3: Feature Adoption Tracking

Track which users have adopted a new feature:

GET /o?api_key={API_KEY}&app_id={APP_ID}&method=user_details
&query={"custom.feature_adopted":true}
&calculate=eventsTable
&period=7days

Purpose: Monitor event patterns among users who've adopted a feature.

Use Case 4: Segmentation by Demographics

Query users by demographic segment:

GET /o?api_key={API_KEY}&app_id={APP_ID}&method=user_details
&query={"cc":"US","age":{$gte:25,$lte:45}}
&sort=sc&order=-1

Purpose: Analyze engagement patterns within demographic segments.

Use Case 5: Individual User Deep Dive

Get complete activity history for a specific user:

GET /o?api_key={API_KEY}&app_id={APP_ID}&method=user_details
&uid={USER_ID}&calculate=eventsTable
&period=90days&bucket=daily

Purpose: Audit complete user journey over extended period.

Best Practices

Query Performance

  1. Use Sampling for Large User Bases: When user count exceeds sampling_threshold, server automatically enables sampling
  2. Limit Query Results: Use iDisplayLength to paginate; avoid requesting all records at once
  3. Add Specific Queries: Narrow queries with filtered query parameter to reduce scope
  4. Sort Efficiently: Sort by indexed fields (sc, ls, tsd, cc) for fastest results
  5. Cache Results: Cache frequently accessed user lists to reduce database load

Custom Property Management

  1. Stay Within Limits: Do not exceed custom_set_limit (default: 50 properties per user)
  2. Use Consistent Keys: Use consistent key naming (e.g., snake_case: subscription_tier, not subscriptionTier)
  3. Type Consistency: Keep same parameter type across all users to avoid type coercion issues
  4. Set Expiration TTL: Configure custom property TTL to auto-clean temporary properties
  5. Regular Audits: Periodically review unused custom properties and clean them

Engagement Scoring

  1. Enable Scoring: Set engagement_score: true in configuration to track engagement metrics
  2. Review Thresholds: Adjust engagement score calculations in application code as needed
  3. Account for Seasonality: Consider seasonal patterns when interpreting engagement trends
  4. Multi-Dimensional Analysis: Combine engagement with custom properties for better insights

Search & Filtering

  1. Full-Text Search: Use sSearch parameter for flexible user lookup across multiple fields
  2. Query Syntax: Use MongoDB query syntax for advanced filtering
  3. Regular Expressions: Match patterns with {field: {$regex: "pattern", $options: "i"}}
  4. Compound Filters: Combine conditions for complex segmentation

Common Parameters & Values

Period Values

Standard time period values for analytics queries:

  • today - Current calendar day
  • yesterday - Previous calendar day
  • 7days - Last 7 calendar days
  • 30days - Last 30 calendar days
  • 60days - Last 60 calendar days
  • 90days - Last 90 calendar days
  • month - Current calendar month
  • year - Current calendar year

Bucket Values

Time aggregation granularity:

  • hourly - Group by hour (for periods up to 3 days)
  • daily - Group by day (default)
  • weekly - Group by ISO week
  • monthly - Group by month

Sort Fields

Common field names for sorting user lists:

FieldDescription
scSession count
eEvent count
lsLast session timestamp (Descending: -1)
tsdTotal session duration (Descending: -1)
dDays active
nameUser name
engagement_scoreEngagement metric

Troubleshooting

Empty User List

Problem: Query returns iTotalRecords: 0 when users should exist

Solutions:

  • Verify API key has read permissions for users analytics
  • Check app_id is correct and contains user data
  • Ensure users have been processed (app_user_job must be enabled)
  • Confirm user has activity data (e.g., hasInfo: true)

Slow Query Performance

Problem: User list queries take > 5 seconds to respond

Solutions:

  • Limit result set with iDisplayLength parameter
  • Add specific query filters to reduce result scope
  • Sort by indexed fields only (e.g., sc, ls, tsd)
  • Check server resource availability (CPU, disk I/O)
  • Consider splitting query into smaller time periods

Custom Properties Not Appearing

Problem: Custom properties aren't showing in custom field

Solutions:

  • Verify custom properties were sent by SDK with user_details parameter
  • Check property count is under custom_prop_limit (default: 20)
  • Confirm property value type is compatible (string, number, array, object)
  • Verify SDK version supports custom user properties
  • Check property wasn't filtered by TTL (Session-scoped properties expire after session)

Engagement Score Not Calculated

Problem: engagement_score field is missing from user profiles

Solutions:

  • Set engagement_score: true in feature configuration
  • Ensure user has at least one session recorded
  • Confirm background jobs are enabled (app_user_job: true)
  • Wait for next aggregation cycle (daily job)
  • Check server logs for job execution errors

Graph Data Missing

Problem: Graph calculation returns empty data with calculate=graph

Solutions:

  • Verify period parameter is reasonable (not more than 1 year)
  • Ensure user has events in selected period
  • Confirm bucket value matches period (e.g., hourly only for periods up to 3 days)
  • Check drill events collection contains data for app_id
  • Verify drill_meta collection exists with event definitions

Search Not Working

Problem: sSearch parameter doesn't return expected users

Solutions:

  • Verify full-text search index was created on app_users collection
  • Check search term appears in name, email, username, or device ID
  • Use substring search: {name: {$regex: "substring", $options: "i"}}
  • Ensure user has hasInfo: true (profile information set)
  • Try reducing search complexity (single term vs. multi-term phrases)

Performance Considerations

  • User Count Impact: Queries on large user bases (100k+) may require sampling
  • Query Complexity: Complex MongoDB queries with $regex or $text operations slower than indexed field lookups
  • Time Period: Longer periods require more drill events processing
  • Batch Processing: Large batch_size may increase memory usage; tune based on available RAM
  • Disk I/O: User list queries hit MongoDB heavily; ensure adequate disk I/O bandwidth

Integration with Other Features

The User Profiles feature integrates with:

  • Drill feature: Extends drill query infrastructure for user-level analytics
  • Data Manager Feature: Users custom properties can be managed through data-manager API
  • Cohorts feature: Users can be organized into cohorts based on custom properties and engagement
  • Crash Reporting: User context automatically captured for crash logs
  • Session Management: Engagement metrics derived from session feature

Additional Resources


Ⓔ Enterprise

This feature is part of Countly Enterprise.

Get Access:

Already a Customer? Use support portal if you have any questions