Behavioral analytics with attribution
Mixpanel excels at behavioral product analytics. By combining Redirectly attribution data with Mixpanel event tracking, you understand not just which campaigns drive installs, but which drive engaged, high-value users. Track user paths, measure feature adoption by campaign, and optimize marketing toward behavioral outcomes.
What Mixpanel measures
- User funnels: Drop-off rates by campaign
- Retention: Which cohorts stay engaged
- User paths: Common feature usage sequences
- Segmentation: Cohort analysis by attribution
- Trend analysis: How campaigns perform over time
Real-world insights
- Organic traffic → High retention, low purchase conversion
- Paid ads → High retention, high purchase rate
- Email re-engagement → Highest lifetime value
- Instagram influencer → Viral potential, high acquisition
- → Optimize marketing mix based on behavior, not just installs
Send attribution events to Mixpanel
Initialize Mixpanel and send attribution data when your app detects a Redirectly deep link on startup.
// lib/services/mixpanel_service.dart
import 'package:mixpanel_flutter/mixpanel_flutter.dart'
import 'package:redirectly/redirectly.dart'
class MixpanelService {
static final Mixpanel _instance = Mixpanel()
static Future<void> initialize(String token) async {
await _instance.init(token)
await _instance.setLoggingEnabled(false)
}
/// Track install with attribution from Redirectly
static Future<void> trackInstallAttribution() async {
try {
final link = await Redirectly.getInitialLink()
if (link != null) {
// Build properties from Redirectly data
final properties = {
'redirectly_link_id': link.id,
'redirectly_path': link.path,
'campaign': link.params['campaign'],
'source': link.params['source'],
'medium': link.params['medium'],
'content': link.params['content'],
'term': link.params['term'],
}
// Track the install event
await _instance.track('Install Attributed', properties)
// Set user properties for segmentation
await _instance.setUserProperties({
'install_link': link.id,
'install_source': link.params['source'],
'install_campaign': link.params['campaign'],
'install_time': DateTime.now().toIso8601String(),
})
print('Tracked install: ${link.id}')
}
} catch (e) {
print('Error tracking install: $e')
}
}
/// Listen for deep links during session
static void listenToDeepLinks() {
Redirectly.onDeepLink.listen((link) {
_instance.track(
'Deep Link Opened',
properties: {
'path': link.path,
'redirectly_link_id': link.id,
'campaign': link.params['campaign'],
'source': link.params['source'],
},
)
})
}
/// Track custom events with attribution context
static Future<void> trackEvent(
String eventName,
Map<String, dynamic>? properties,
) async {
final link = await Redirectly.getInitialLink()
final eventProperties = {
...?properties,
if (link != null) ...{
'install_source': link.params['source'],
'install_campaign': link.params['campaign'],
},
}
await _instance.track(eventName, eventProperties)
}
}
Initialize this in your app's main entry point:
// main.dart
void main() async {
WidgetsFlutterBinding.ensureInitialized()
await Redirectly.initialize(apiKey: 'your_redirectly_key')
await MixpanelService.initialize('your_mixpanel_token')
// Track initial attribution
await MixpanelService.trackInstallAttribution()
// Listen for future deep links
MixpanelService.listenToDeepLinks()
runApp(const MyApp())
}
Track user behavior with attribution context
Log every important user action with campaign attribution. This reveals which channels drive engaged users.
// lib/screens/auth_screen.dart
class AuthScreen extends StatelessWidget {
Future<void> handleSignup(String email, String password) async {
try {
// Sign up the user
final user = await _auth.signup(email, password)
// Track signup with attribution
await MixpanelService.trackEvent(
'Signup Completed',
{'email': email, 'user_id': user.id},
)
Navigator.pushReplacementNamed(context, '/home')
} catch (e) {
print('Signup error: $e')
}
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: const Text('Sign Up')),
body: Column(
children: [
TextField(
onChanged: (value) {
// Track field interaction
MixpanelService.trackEvent('Signup Form Focused')
},
),
ElevatedButton(
onPressed: () => handleSignup(email, password),
child: const Text('Sign Up'),
),
],
),
)
}
}
// lib/screens/home_screen.dart
class HomeScreen extends StatefulWidget {
@override
void initState() {
super.initState()
// Track screen view
MixpanelService.trackEvent('Home Screen Viewed')
}
void handlePurchase(String productId, double amount) async {
await _stripe.charge(amount)
// Track purchase with attribution
await MixpanelService.trackEvent(
'Purchase Completed',
{
'product_id': productId,
'amount': amount,
},
)
}
void shareWithFriend(String friendEmail) async {
// Generate Redirectly referral link
final referralLink = await Redirectly.createLink(
path: 'referral',
params: {
'referrer_id': currentUser.id,
'referrer_email': currentUser.email,
},
)
// Track referral event
await MixpanelService.trackEvent(
'Referral Shared',
{
'friend_email': friendEmail,
'referral_link': referralLink,
},
)
// Share via email/SMS
await Share.share('Join me: $referralLink')
}
}
Analyze funnels by campaign source
In Mixpanel, create funnels that show how users from each campaign progress through your app.
Setup funnel in Mixpanel
Create a funnel with these steps:
1. Install Attributed
2. Signup Completed
3. First Purchase Completed
Segment by: install_source
Typical funnel results
You might see something like:
Instagram: 1000 installs → 200 signups (20%) → 30 purchases (3%)
Email: 100 installs → 85 signups (85%) → 25 purchases (25%)
Organic: 500 installs → 75 signups (15%) → 15 purchases (3%)
Use insights to optimize
If email drives 5x higher conversion despite lower volume, shift budget toward email. If Instagram has low conversion but high viral potential, focus on amplifying top creators.
Discover user paths by attribution
Use Mixpanel's User Path analysis to see how users from each campaign navigate your app.
// Example: Set detailed user properties for path analysis
Future<void> setDetailedUserProperties() async {
final link = await Redirectly.getInitialLink()
if (link != null) {
await mixpanel.setUserProperties({
// Campaign attribution
'install_campaign': link.params['campaign'],
'install_source': link.params['source'],
// Device info
'device_type': deviceType,
'os_version': osVersion,
// Behavioral properties
'is_power_user': false, // Update as user engages
'feature_interest': [], // Build as user explores
'price_sensitivity': 'unknown', // Learn from behavior
})
}
}
// Then track events:
// Home Screen Viewed → Browse Products → Add to Cart → Purchase
// Mixpanel will show:
// "Instagram users spend 40s on Product pages"
// "Email users buy within 2 hours of install"
// "Organic users have 5x higher churn"
Next steps
Optimize your marketing with behavioral attribution insights: