Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions api-reference/event-capture.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ POST: /capture-event
"currency": "USD",
"is_featured": true
},
"user_id": "user_12345"
"user_id": "user_12345",
"event_id": "550e8400-e29b-41d4-a716-446655440000"
}
```

Expand All @@ -49,6 +50,7 @@ POST: /capture-event
| event_name | string | **Required**. Name of the event to track |
| event_data | object | **Optional**. Additional data associated with the event |
| user_id | string | **Required**. User identifier to associate with the event |
| event_id | string | **Optional**. Unique event identifier (String) for deduplication. If you're tracking the same event from both your app (SDK) and backend (API), make sure to send the same `event_id` from both sources |

### Responses

Expand Down Expand Up @@ -97,7 +99,8 @@ To enable revenue sharing with ad networks like Google Ads and Meta, include an
"category": "electronics",
"amount": 149.99
},
"user_id": "user_12345"
"user_id": "user_12345",
"event_id": "550e8400-e29b-41d4-a716-446655440000"
}
```

Expand All @@ -106,6 +109,10 @@ To enable revenue sharing with ad networks like Google Ads and Meta, include an
string.
</Note>

<Note>
The `event_id` parameter is optional and should be a unique String identifier for each event. It's used for deduplication on the server side. If you're tracking the same event from both your app (SDK) and backend (API), make sure to send the same `event_id` from both sources to prevent duplicate event tracking.
</Note>

## Best Practices

1. **Consistent naming**: Use consistent naming conventions for your events (snake_case is recommended)
Expand All @@ -118,7 +125,6 @@ To enable revenue sharing with ad networks like Google Ads and Meta, include an
### Tracking a Purchase Event

```javascript
// Using fetch API
fetch("https://api.linkrunner.io/api/v1/capture-event", {
method: "POST",
headers: {
Expand All @@ -135,6 +141,7 @@ fetch("https://api.linkrunner.io/api/v1/capture-event", {
payment_method: "credit_card",
},
user_id: "user_12345",
event_id: "550e8400-e29b-41d4-a716-446655440000", // Optional: Unique event identifier for deduplication. Use the same event_id if tracking from both SDK and API
}),
})
.then((response) => response.json())
Expand Down
13 changes: 10 additions & 3 deletions sdk/android.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,8 @@ private fun trackEvent() {
"product_id" to "12345",
"category" to "electronics",
"amount" to 99.99 // Include amount as a number for revenue sharing with ad networks like Google and Meta
)
),
eventId = "550e8400-e29b-41d4-a716-446655440000" // Optional: Unique event identifier (String) for deduplication
)

result.onSuccess {
Expand All @@ -350,6 +351,10 @@ private fun trackEvent() {
}
```

<Note>
The `eventId` parameter is optional and should be a unique String identifier for each event. It's used for deduplication on the server side. If you're tracking the same event from both your app and backend, make sure to send the same `eventId` from the [Event Capture API](/api-reference/event-capture) as well.
</Note>

### Revenue Sharing with Ad Networks

To enable revenue sharing with ad networks like Google Ads and Meta, include an `amount` parameter as a number in your custom event data. This allows the ad networks to optimize campaigns based on the revenue value of conversions:
Expand All @@ -364,7 +369,8 @@ private fun trackPurchaseEvent() {
"product_id" to "12345",
"category" to "electronics",
"amount" to 149.99 // Revenue amount as a number
)
),
eventId = "550e8400-e29b-41d4-a716-446655440000" // Optional: Unique event identifier (String) for deduplication
)

result.onSuccess {
Expand Down Expand Up @@ -605,7 +611,8 @@ class MainActivity : AppCompatActivity() {
try {
LinkRunner.getInstance().trackEvent(
eventName = "button_clicked",
eventData = mapOf("screen" to "main")
eventData = mapOf("screen" to "main"),
eventId = "550e8400-e29b-41d4-a716-446655440000" // Optional: Unique event identifier (String) for deduplication
)
} catch (e: Exception) {
println("Error tracking event: ${e.message}")
Expand Down
11 changes: 10 additions & 1 deletion sdk/flutter.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,7 @@ Future<void> trackEvent() async {
'category': 'electronics',
'amount': 99.99, // Include amount as a number for revenue sharing with ad networks like Google and Meta
},
eventId: '550e8400-e29b-41d4-a716-446655440000', // Optional: Unique event identifier (String) for deduplication
);
print('Event tracked successfully');
} catch (e) {
Expand All @@ -355,6 +356,10 @@ Future<void> trackEvent() async {
}
```

<Note>
The `eventId` parameter is optional and should be a unique String identifier for each event. It's used for deduplication on the server side. If you're tracking the same event from both your app and backend, make sure to send the same `eventId` from the [Event Capture API](/api-reference/event-capture) as well.
</Note>

### Revenue Sharing with Ad Networks

To enable revenue sharing with ad networks like Google Ads and Meta, include an `amount` parameter as a number in your custom event data. This allows the ad networks to optimize campaigns based on the revenue value of conversions:
Expand All @@ -369,6 +374,7 @@ Future<void> trackPurchaseEvent() async {
'category': 'electronics',
'amount': 149.99, // Revenue amount as a number
},
eventId: '550e8400-e29b-41d4-a716-446655440000', // Optional: Unique event identifier (String) for deduplication
);
print('Purchase event with revenue tracked successfully');
} catch (e) {
Expand Down Expand Up @@ -737,7 +743,10 @@ class _HomeScreenState extends State<HomeScreen> {
SizedBox(height: 20),
ElevatedButton(
onPressed: () async {
await LinkRunner().trackEvent(eventName: 'button_clicked');
await LinkRunner().trackEvent(
eventName: 'button_clicked',
eventId: '550e8400-e29b-41d4-a716-446655440000', // Optional: Unique event identifier (String) for deduplication
);
},
child: Text('Track Custom Event'),
),
Expand Down
Loading