Analytics tracking and real-time personalisation for Flutter apps, powered by Reelevant.
π Full documentation
flutter pub add reelevant_analytics
See pub.dev for more information.
You need a datasourceId and a companyId to initialise the SDK:
final rlvt = ReelevantAnalytics(companyId: '<company id>', datasourceId: '<datasource id>');var event = rlvt.pageView(labels: {});
rlvt.send(event);When a user is browsing a page you should call the rlvt.setCurrentURL method if you want to be able to filter on it in Reelevant.
To identify a user, call rlvt.setUser('<user id>') β the SDK stores the user ID on-device and sends it with every event and personalization call.
Each event type allows you to pass additional info via labels (Map<String, String>) on which you'll be able to filter in Reelevant.
var event = rlvt.addCart(ids: ['my-product-id'], labels: {'lang': 'en_US'});The SDK can call the Reelevant runner to fetch personalised content for your app. Identity is automatically resolved from setUser() / device ID β no need to pass it manually.
Personalization parameters are optional (defaults work out of the box):
final rlvt = ReelevantAnalytics(
companyId: '...',
datasourceId: '...',
// optional β defaults below
runnerUrl: 'https://reelevant.run',
runnerTimeout: Duration(seconds: 5),
fallback: FallbackStrategy.empty,
);final result = await rlvt.run(RunOptions(
workflowId: 'wf-hero',
entrypoint: '43a490a0',
));
if (result.body is JsonRunContent) {
final data = (result.body as JsonRunContent).content;
renderCard(data);
} else if (result.body is HtmlRunContent) {
loadHtml((result.body as HtmlRunContent).content);
} else if (result.body is ImageRunContent) {
displayImage((result.body as ImageRunContent).content);
} else {
showDefault();
}final results = await rlvt.runAll([
RunOptions(workflowId: 'wf-hero', entrypoint: '43a490a0'),
RunOptions(workflowId: 'wf-sidebar', entrypoint: 'b7e21f3c'),
]);Every RunResult includes a redirectionUrl (for use as a link href) and a trackClick() method for fire-and-forget server-side tracking:
// Option 1: Use redirectionUrl as a link
launchUrl(Uri.parse(result.redirectionUrl));
// Option 2: Track the click programmatically
await result.trackClick();| Field | Type | Description |
|---|---|---|
status |
int |
HTTP status code (0 for fallback) |
source |
RunSource |
runner or fallback |
body |
RunContent |
Typed content (JsonRunContent, HtmlRunContent, ImageRunContent, or EmptyRunContent) |
metadata |
Map<String, dynamic> |
Metadata from the output node |
properties |
Map<String, dynamic> |
Output properties |
runId |
String? |
Workflow run ID for tracking |
executionPath |
List<String> |
Branch IDs taken during execution |
redirectionUrl |
String |
Pre-built click-through URL |
// Default β returns an empty result on error
FallbackStrategy.empty
// Throws the underlying error
FallbackStrategy.error| Option | Type | Description |
|---|---|---|
workflowId |
String |
Workflow ID |
entrypoint |
String |
Entrypoint shortId |
userId |
String? |
Override identity (default: auto-resolved) |
params |
Map<String, String>? |
URL parameters forwarded to runner |
locale |
String? |
Locale for content resolution |
timeout |
Duration? |
Per-call timeout override |
This project is a Flutter plug-in package, a specialized package that includes platform-specific implementation code for Android and iOS.
For help getting started with Flutter development, view the online documentation, which offers tutorials, samples, guidance on mobile development, and a full API reference.