linklytics_flutter 1.1.8
linklytics_flutter: ^1.1.8 copied to clipboard
A Flutter plugin for integrating Linklytics analytics into your Flutter applications.
Linklytics Flutter Plugin #
A comprehensive Flutter plugin for integrating Linklytics analytics, deep linking, and community features into your application.
Features #
- 📊 Analytics: Track custom events, user interactions, and app performance.
- 🔗 Deep Linking: Handle deferred deep links (attribution) and universal links.
- 🛠 Dynamic Links: Generate short tracking links programmatically.
- 💬 Community & Blog: Built-in UI for community forums and blogs (powered by Linklytics).
Installation #
Add this to your package's pubspec.yaml file:
dependencies:
linklytics_flutter: ^1.1.8
Then run:
flutter pub get
Usage #
1. Initialization #
Initialize the SDK early in your app's lifecycle (e.g., in main.dart).
import 'package:linklytics_flutter/linklytics_flutter.dart';
void main() async {
WidgetsFlutterBinding.ensureInitialized();
// Create an instance
final linklytics = LinklyticsFlutter();
// Initialize with your API Key
await linklytics.initialize(
apiKey: 'YOUR_API_KEY',
isDebug: true, // Enable logs for debugging
);
runApp(MyApp());
}
2. Tracking Events #
Send custom events to track user actions.
final linklytics = LinklyticsFlutter();
await linklytics.sendEvent(
'purchase_completed',
{
'item_id': 'sku_123',
'value': 99.99,
'currency': 'USD'
}
);
3. Handling Deep Links #
Listen for deep links (including deferred links from installs).
// Check for links on app start or when resumed
final linklytics = LinklyticsFlutter();
await linklytics.getLink((DeepLinkRoute route) {
print("Deep Link Received: ${route.route}");
print("Parameters: ${route.parameters}");
// Navigate based on route
if (route.route.contains('/product')) {
// navigatorKey.currentState?.pushNamed(...)
}
});
4. Generating Dynamic Links #
Create short tracking links programmatically to share content.
final linklytics = LinklyticsFlutter();
String? shortUrl = await linklytics.generateLink(
route: 'product/123',
params: {
'referrer': 'user_456',
'source': 'share_button'
},
shortLink: true // Set to false for long URL
);
print("Share this link: $shortUrl");
5. Community & Blogs (UI) #
Linklytics comes with pre-built Community and Blog pages.
Required Setup:
Ensure GetX and Dio are initialized in your app.
void main() {
Get.put(Dio()); // Required for network calls
LinklyticsNavigator.initializeControllers(); // Initialize controllers
runApp(MyApp());
}
Open Community:
ElevatedButton(
onPressed: () {
LinklyticsNavigator.openCommunities();
},
child: Text("Open Community"),
)
Open Blogs:
ElevatedButton(
onPressed: () {
LinklyticsNavigator.openBlogs();
},
child: Text("Read Blog"),
)
Platform Support #
| Platform | Support | Min Version |
|---|---|---|
| Android | ✅ | API 21+ |
| iOS | ✅ | iOS 11.0+ |
License #
This project is licensed under the MIT License - see the LICENSE file for details.