Overview
Track deep link conversions to attribute app installs and user actions to specific Smler short links. This is essential for measuring campaign performance and understanding user acquisition.
Track Conversion API
Endpoint
POST https://smler.in/api/v2/track/:clickId
Marks a deep link click as converted after an app install or desired action.
Parameters
Parameter | Location | Required | Description |
|---|---|---|---|
| Path | Yes | Unique identifier for the click event |
| Body | Yes | Short code from your Smler link (e.g., "uber-demo") |
| Body | Yes | Domain used for the short link (e.g., "smler.in") |
Request Example
curl --location 'https://smler.in/api/v2/track/6655332' \
--header 'Content-Type: application/json' \
--data '{
"shortCode": "uber-demo",
"domain": "smler.in"
}'Implementation Guide
Step 1: Extract Deep Link Data
When your app opens via a deep link, extract the necessary information:
Android - URL format: https://yourdomain.com/short-code?clickId=1234 (URL encoded)
val data: Uri? = intent?.data
val shortCode = data?.lastPathSegment
val domain = data?.hostiOS - URL format: https://yourdomain.com/short-code?clickId=1234 (also copied to clipboard)
let shortCode = url.lastPathComponent
let domain = url.host ?? ""Step 2: Pass the clickId
The click ID should be stored when the user clicks and passed on to smler in request. This helps smler identify which click has lead to conversion in you dashboard
Step 3: Track the Conversion
Call the tracking API with the extracted data:
Android (Kotlin)
fun trackConversion(clickId: String, shortCode: String, domain: String) {
val client = OkHttpClient()
val json = JSONObject().apply {
put("shortCode", shortCode)
put("domain", domain)
}
val requestBody = json.toString()
.toRequestBody("application/json".toMediaTypeOrNull())
val request = Request.Builder()
.url("https://smler.in/api/v2/track/$clickId")
.post(requestBody)
.build()
client.newCall(request).enqueue(object : Callback {
override fun onResponse(call: Call, response: Response) {
Log.d("Smler", "Conversion tracked")
}
override fun onFailure(call: Call, e: IOException) {
Log.e("Smler", "Tracking failed", e)
}
})
}iOS (Swift)
func trackConversion(clickId: String, shortCode: String, domain: String) {
let url = URL(string: "https://smler.in/api/v2/track/\(clickId)")!
var request = URLRequest(url: url)
request.httpMethod = "POST"
request.setValue("application/json", forHTTPHeaderField: "Content-Type")
let body: [String: String] = [
"shortCode": shortCode,
"domain": domain
]
request.httpBody = try? JSONSerialization.data(withJSONObject: body)
URLSession.shared.dataTask(with: request) { data, response, error in
if error != nil {
print("Tracking failed")
} else {
print("Conversion tracked")
}
}.resume()
}JavaScript/React Native
async function trackConversion(clickId, shortCode, domain) {
try {
const response = await fetch(`https://smler.in/api/v2/track/${clickId}`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ shortCode, domain })
});
if (response.ok) {
console.log('Conversion tracked');
}
} catch (error) {
console.error('Tracking failed:', error);
}
}When to Track
First Launch (Deferred Deep Link) Track conversion on first app launch after installation:
// Android
val isFirstLaunch = sharedPrefs.getBoolean("is_first_launch", true)
if (isFirstLaunch && clickId != null) {
trackConversion(clickId, shortCode, domain)
sharedPrefs.edit().putBoolean("is_first_launch", false).apply()
}Smler currently recommends marking download as conversion. You could also optionally send the conversion tracking after a user signs up or does an action. As long as the click Id is send smler will mark it as conversion. Along with just true or false. You also send optional payload as meta data for conversion. Read through it in postman collection
Best Practices
Track Once: Only track each conversion once to avoid duplicate data
Handle Errors: Implement retry logic for failed network requests
Clear Storage: Remove stored click IDs after successful tracking
Testing
Verify tracking is working:
Click a Smler short link
Install/open your app
Check that the API call is made with correct parameters
Verify conversion appears in Smler dashboard
Test command (Android ADB):
adb shell am start -W -a android.intent.action.VIEW \ -d "https://yourdomain.com/your-short-code" com.your.packageTroubleshooting
Issue | Solution |
|---|---|
Conversion not tracked | Verify click ID is stored and retrieved correctly |
Invalid click ID error | Ensure click ID is captured when link is first clicked |
Network timeout | Implement retry mechanism with exponential backoff |
Wrong attribution | Double-check shortCode and domain match the original link |
Need Help? Check the full Smler API documentation or visit app.smler.io
Published with LeafPad