linkrunner 1.0.1
linkrunner: ^1.0.1 copied to clipboard
Flutter Package for linkrunner, track every click, download and dropoff for your app links
linkrunner #
Flutter Package for linkrunner.io
Table of Contents #
Installation #
Step 1: Installing linkrunner #
Installing through cmdline
run the following:
flutter pub add linkrunner
OR
Manually adding dependencies
Add linkrunner
to your pubspec.yaml
under dependencies:
dependencies:
linkrunner: ^0.7.9
Then run:
flutter pub get
to install your new dependency.
Step 2: Android updates #
Add the following in app/build.gradle
file
dependencies {
...
implementation("com.android.installreferrer:installreferrer:2.2")
}
Step 3: IOS updates #
Add the following in info.plist
:
<key>NSUserTrackingUsageDescription</key>
<string>This identifier will be used to deliver personalized ads to you.</string>
Usage #
Initialisation #
You will need your project token to initialise the package.
Place it in the main
function:
import 'package:linkrunner/main.dart';
// Initialize the package
final linkrunner = LinkRunner();
void main() async {
// Call the .ensureInitialized method before calling the .init method
WidgetsFlutterBinding.ensureInitialized();
final init = await lr.init("YOUR_PROJECT_TOKEN");
runApp(MyApp());
}
Response type for linkrunner.init
{
ip_location_data: {
ip: string;
city: string;
countryLong: string;
countryShort: string;
latitude: number;
longitude: number;
region: string;
timeZone: string;
zipCode: string;
};
deeplink: string;
root_domain: boolean;
campaign_data: {
id: string;
name: string;
type: "ORGANIC" | "INORGANIC";
ad_network: "META" | "GOOGLE" | null;
group_name: string | null;
asset_group_name: string | null;
asset_name: string | null;
};
}
Signup #
Call this function only once after the user has completed the onboarding process in your app. This should be triggered at the final step of your onboarding flow to register the user with Linkrunner.
import 'package:linkrunner/main.dart';
void signup() async {
final signup = await linkrunner.signup(
userData: LRUserData(
id: '1',
name: 'John Doe', // optional
phone: '9583849238', // optional
email: 'support@linkrunner.io', //optional
),
data: {}, // Any other data you might need
);
}
You can pass any additional user related data in the data
attribute
Response type for linkrunner.signup
{
ip_location_data: {
ip: string;
city: string;
countryLong: string;
countryShort: string;
latitude: number;
longitude: number;
region: string;
timeZone: string;
zipCode: string;
};
deeplink: string;
root_domain: boolean;
}
Set User Data #
Call this function everytime the app is opened and the user is logged in.
import 'package:linkrunner/main.dart';
void setUserData() async {
await linkrunner.setUserData(
userData: LRUserData(
id: '1',
name: 'John Doe', // optional
phone: '9583849238', // optional
email: 'support@linkrunner.io', //optional
),
);
}
Trigger Deeplink (For Deferred Deep Linking) #
This function triggers the original deeplink that led to the app installation. Call it only after your main navigation is initialized and all deeplink-accessible screens are ready to receive navigation events.
Note: For this to work properly make sure you have added verification objects on the Linkrunner Dashboard.
import 'package:linkrunner/main.dart';
void triggerDeeplink() async {
await linkrunner.triggerDeeplink();
}
Track Event #
Use this method to track custom events
import 'package:linkrunner/main.dart';
void trackEvent() async {
await linkrunner.trackEvent(
eventName: 'event_name', // Name of the event
eventData: { 'key': 'value' } // Optional: Additional JSON data for the event
);
}
Capture revenue #
Call this function after a payment is confirmed
import 'package:linkrunner/models/lr_capture_payment.dart';
void capturePayment() async {
await linkrunner.capturePayment(
capturePayment: LRCapturePayment(
userId: '666',
amount: 24168, // Send amount in one currency only
paymentId: 'AJKHAS' // optional but recommended
),
);
}
NOTE: If you accept payments in multiple currencies convert them to one currency before calling the above function
Remove captured payment revenue #
Call this function after a payment is cancelled or refunded
import 'package:linkrunner/models/lr_remove_payment.dart';
void removeCapturedPayment() async {
await linkrunner.removePayment(
removePayment: LRRemovePayment(
userId: '666',
paymentId: 'AJKHAS' // Ethier paymentId or userId is required!
),
);
}
NOTE: userId
or paymentId
is required in order to remove a payment entry, if you use userId all the payments attributed to that user will be removed
Function Placement Guide #
Below is a simple guide on where to place each function in your application:
Function | Where to Place | When to Call |
---|---|---|
linkrunner.init |
In your main.dart within a WidgetsFlutterBinding.ensureInitialized |
Once when the app starts |
linkrunner.signup |
In your onboarding flow | Once after user completes the onboarding process |
linkrunner.setUserData |
In your authentication logic | Every time the app is opened and the user is logged in |
linkrunner.triggerDeeplink |
After navigation initialization | Once after your navigation is ready to handle deep links |
linkrunner.trackEvent |
Throughout your app where events need to be tracked | When specific user actions or events occur |
linkrunner.capturePayment |
In your payment processing flow | When a user makes a payment |
linkrunner.removePayment |
In your payment cancellation/refund flow | When a payment needs to be removed |
Facing issues during integration? #
Email us at support@linkrunner.io
License #
MIT