The Smler React Native SDK provides two mechanisms for notifying your backend about deep link activity: webhook notifications and click tracking.
Webhook Notifications
Webhooks notify the Smler backend that a short link was opened, allowing it to fire the webhook you have configured in the Smler dashboard. There are two ways to trigger a webhook:
Option 1: Inline with resolveDeepLink() (Recommended)
The simplest approach is to pass triggerWebhook: true when resolving a deep link. The Smler backend fires the webhook as part of the same API call — no additional request needed:
import { SmlerDeferredLink } from '@smler/deferred-link';
const data = await SmlerDeferredLink.resolveDeepLink(
'https://go.yourdomain.com/abc123',
{ triggerWebhook: true }
);
// Webhook was already fired server-side
console.log('Resolved:', data.originalUrl);Behind the scenes, this appends &triggerWebhook=true to the Smler API request, and the server handles the webhook dispatch in the same request.
Option 2: Standalone triggerWebhook() Call
If you need to trigger the webhook separately (for example, after performing additional logic), use HelperReferrer.triggerWebhook():
import { SmlerDeferredLink, HelperReferrer } from '@smler/deferred-link';
import type { WebhookResponse } from '@smler/deferred-link';
// First, resolve the deep link
const data = await SmlerDeferredLink.resolveDeepLink(
'https://go.yourdomain.com/BKMTCH/Ffo6TOPIkd'
);
// Then trigger the webhook with the resolved data
if (data.shortCode && data.domain) {
const response: WebhookResponse = await HelperReferrer.triggerWebhook({
shortCode: data.shortCode,
domain: data.domain,
dltHeader: data.dltHeader, // optional
});
if (response.success) {
console.log('Webhook triggered successfully');
} else {
console.error('Webhook failed:', response.error, response.message);
}
}triggerWebhook() Parameters
Parameter | Type | Required | Description |
|---|---|---|---|
|
| Yes | The short URL code from the resolved link |
|
| Yes | The domain from the resolved link |
|
| No | Campaign/category header, if present |
WebhookResponse
Field | Type | Description |
|---|---|---|
|
| Whether the webhook was triggered successfully |
|
| Error code if the request failed |
|
| Error message if the request failed |
The webhook sends a POST request to: https://smler.in/api/v1/webhook?shortCode=<code>&domain=<domain>&dltHeader=<header>
Click Tracking
Click tracking is an feature that reports a click event back to the Smler API. It is shown in dashboard as a conversion event
How It Works
When the referrer string from Google Play contains a clickId query parameter, the trackClick() method:
Extracts
clickIdfrom the referrer query parametersExtracts
shortCodeanddltHeaderfrom the referrer URL pathExtracts the
domainfrom the referrer URL hostnameSends a
POSTrequest tohttps://smler.in/api/v2/track/{clickId}with the extracted data
Usage
import { SmlerDeferredLink } from '@smler/deferred-link';
const info = await SmlerDeferredLink.getInstallReferrerAndroid();
const tracking = await SmlerDeferredLink.trackClick(info);
if (tracking) {
console.log('Click tracked:', tracking);
} else {
console.log('No clickId in referrer — nothing to track');
}Returns:
A
TrackingResponseobject on successnullif noclickIdwas found in the referrer string
TrackingResponse
Field | Type | Description |
|---|---|---|
|
| Error code if the request failed |
|
| Error message if the request failed |
The response may also contain additional fields returned by the Smler tracking API.
Using fetchTrackingData() Directly
For lower-level control, you can call HelperReferrer.fetchTrackingData() directly with your own parameters:
import { HelperReferrer } from '@smler/deferred-link';
const result = await HelperReferrer.fetchTrackingData(
'my-click-id',
{ shortCode: 'abc123', dltHeader: 'BKMTCH' },
'go.yourdomain.com'
);
if (!result.error) {
console.log('Tracking data:', result);
}Combined Flow Example
Here's a typical flow that uses both click tracking and webhooks:
import { Platform } from 'react-native';
import { SmlerDeferredLink, HelperReferrer } from '@smler/deferred-link';
async function handleAttribution() {
if (Platform.OS === 'android') {
// Read referrer and track click
const info = await SmlerDeferredLink.getInstallReferrerAndroid();
await SmlerDeferredLink.trackClick(info);
// Resolve the link with webhook
const { shortCode, dltHeader } =
SmlerDeferredLink.extractShortCodeAndDltHeader(info);
if (shortCode) {
const data = await SmlerDeferredLink.resolveDeepLink(
`https://go.yourdomain.com/${dltHeader ? dltHeader + '/' : ''}${shortCode}`,
{ triggerWebhook: true }
);
// Navigate based on data.originalUrl
}
} else if (Platform.OS === 'ios') {
// Clipboard check
const result = await SmlerDeferredLink.getInstallReferrerIos({
deepLinks: ['go.yourdomain.com'],
});
if (result) {
// track the click for conversion
const result = await SmlerDeferredLink.trackClick(info);
// Navigate based on data.originalUrl
}
}
}
Published with LeafPad