API tracking for Android apps
API Tracking is a part of the Apptics Analytics SDK that automatically tracks the success rate, response time, and status of your application's network requests. Once configured, all supported API calls are monitored and reported to the Apptics dashboard without requiring API registration in the Apptics web console. (Refer to the User Guide to configure APIs in the web console.)
Before you begin, make sure that Apptics is integrated into your project by following the Integration Guide.
Copieddependencies {
// ...
// Apptics BoM, latest version is mentioned in the integration guide.
implementation platform('com.zoho.apptics:apptics-bom:[latest-version]')
// Since BoM version is specified, no need to explicitly specify the dependency version.
implementation 'com.zoho.apptics:apptics-analytics'
}If you do not use Apptics BoM, you can directly declare the analytics dependency with its version.
Copieddependencies {
// Have to explicitly mention the version, if you are not using BoM.
// latest version is mentioned in the integration guide.
implementation 'apptics_android_sdk.milestones:analytics:[latest-version]'
}Note: It is recommend to use Apptics BoM to avoid unnecessary compatibility issues.
Initialize analytics in application onCreate() method.
CopiedApptics.init(this)Tracking APIs
For retrofit users
Add AppticsAnalyticsApiTrackingInterceptor to your Okhttp client builder used to make API calls.
CopiedOkHttpClient client = new OkHttpClient.Builder()
.addInterceptor(new AppticsApiTrackingInterceptor())
.build();Migration note: @TrackApiWith annotations and API registration in the Apptics web console are no longer required.
For users using other networking libraries
Use startTrackApi method with the API ID and the request method (GET, POST, PUT, etc.) before making network call.
Copiedval trackId = AppticsApiTracker.startTrackApi(Url, requestMethod)The startTrackApi will return a tracking id. Use that id along with the API response code (200, 400, etc.) in the endTrackApimethod. Call endTrackApi method once the API has returned the response.
CopiedAppticsApiTracker.endTrackApi(trackId, responseCode)Endpoint normalization
Before recording a request, the SDK normalizes the URL path to group dynamic segments together.
Raw URL | Normalized path |
GET /users/42/orders | /users/*/orders |
GET /users/550e8400-e29b-41d4-a716-446655440000/profile | /users/*/profile |
DELETE /sessions/eyJhbGci... | /sessions/* |
GET /products/search | /products/search(static, unchanged) |
The following segment types are detected automatically and replaced with *:
- Numeric IDs: pure digit sequences (e.g. 42, 1000203)
- UUIDs: standard 8-4-4-4-12 hex format
- JWT tokens: three base64url segments separated by dots
Query strings are stripped before recording.
Filtering which APIs should be tracked
By default, all requests through the interceptor are tracked. Use AppticsApiTracker.configure method to restrict or customize what gets tracked. Call configure once during app startup, before any network requests are made (e.g. in Application.onCreate() after AppticsAnalytics.init()).
Ignore specific third-party domains
CopiedAppticsApiTracker.configure {
ignoreDomains("crashlytics.com", "analytics.google.com")
}Track only your own APIs (allow-list)
CopiedAppticsApiTracker.configure {
allowOnlyDomains("api.yourapp.com", "cdn.yourapp.com")
}Any domain not in the list is silently skipped.
Filter by top-level domain (TLD)
Track only requests to .com and .io domains
CopiedAppticsApiTracker.configure {
allowOnlyTLDs(".com", ".io")
}Ignore all requests to .internal domains
CopiedAppticsApiTracker.configure {
ignoreTLDs(".internal", ".local")
}Ignore domains by prefix or suffix
CopiedAppticsApiTracker.configure {
ignoreDomainPrefixes("dev.", "staging.") // ignores dev.api.com, staging.api.com, etc.
ignoreDomainSuffixes(".cdn.net") // ignores assets.cdn.net, images.cdn.net, etc.
}Group regional domains
If your API is served from multiple regional domains (e.g. api.myapp.com, api.myapp.in, api.myapp.ae), use groupDomains to aggregate them under a single wildcard hostname in your analytics:
CopiedAppticsApiTracker.configure {
groupDomains("api.myapp.*")
}| Original Domain | Grouped as |
api.myapp.com | api.myapp.* |
api.myapp.in | api.myapp.* |
api.myapp.ae | api.myapp.* |
api.myapp.eu | api.myapp.* |
You can specify multiple domain groups:
CopiedAppticsApiTracker.configure {
groupDomains(
"api.myapp.*", // api.myapp.com, api.myapp.in, api.myapp.ae
"analytics.myapp.*", // analytics.myapp.com, analytics.myapp.in
"cdn.myapp.*" // cdn.myapp.com, cdn.myapp.net
)
}Ignore specific endpoint paths
CopiedAppticsApiTracker.configure {
ignoreEndpoint(
"/health", // exact match
"/internal/*", // wildcard — matches /internal/ping, /internal/metrics, etc.
"/debug/**" // prefix match — matches anything under /debug/
)
}Pattern syntax to follow
- Exact: No wildcards, must match the full path (e.g. /health)
- Wildcard *: Matches any single path segment (e.g. /internal/*
- Placeholder {name}: Same as *, matches any single segment (e.g. /users/{id}/profile
- Prefix **: Must appear at the end, matches everything after the prefix (e.g. /debug/**)
Both * and {placeholder} syntax are supported for consistency with addPattern().
CopiedAppticsApiTracker.configure {
// These are equivalent:
ignoreEndpoint("/users/*/orders")
ignoreEndpoint("/users/{userId}/orders")
}Customizing normalization
Define explicit patterns for your endpoints.
If auto-detection normalizes a segment it shouldn't (or misses one), define an explicit pattern using {placeholder} syntax for dynamic segments:
CopiedAppticsApiTracker.configure {
addPattern("/v1/accounts/{accountId}/users/{userId}")
addPattern("/api/{version}/products/{sku}/reviews")
}Patterns are matched before auto-detection runs. If a pattern matches, the result is used as-is and auto-detection is skipped for that path.
Protect static segments from being normalized
If a segment looks numeric or UUID-like but is actually meaningful (e.g. a version number like v2 or a fixed resource name like 404), preserve it:
CopiedAppticsApiTracker.configure {
preserveSegments("v1", "v2", "v3", "404", "500")
}Preserved segments are never replaced with *, regardless of their format.
Disable auto-detection entirely
If you want to control normalization exclusively through explicit patterns:
CopiedAppticsApiTracker.configure {
autoDetection(false)
addPattern("/users/{id}")
addPattern("/orders/{orderId}/items/{itemId}")
}With auto-detection off, only paths matching a defined pattern are normalized; all other paths are recorded as-is.
Combining options
All options can be combined in a single configure block:
CopiedAppticsApiTracker.configure {
// Only track your own APIs
allowOnlyDomains("api.yourapp.com", "api.yourapp.in", "api.yourapp.ae")
// Group regional domains for cleaner analytics
groupDomains("api.yourapp.*")
// Skip health and internal endpoints
ignoreEndpoint("/health", "/ping", "/internal/**")
// Explicit patterns take priority over auto-detection
addPattern("/v2/catalog/{categoryId}/items/{itemId}")
// Protect version segments
preserveSegments("v1", "v2")
}