Events Integration
Track user actions with Weespin (logEvent, setUserId, initializeDevice)
Track user behavior and analytics in your Flutter application with Weespin's event tracking system to measure conversions, analyze engagement, and optimize your campaigns.
Thanks to the Weespin package, you can:
- Track custom events (purchases, sign-ups, add to cart).
- Associate events with users and generated links.
- Collect valuable data to improve your product.
Prerequisites: Get your API keys
- Log into your Weespin dashboard.
- Go to your application.
- Go to the Configuration section.
- In Integration:
- Generate the API key that will be used to identify your application.
Store your keys in a secure file or environment variables.
Integrate the Weespin Flutter plugin
- Add the dependency in
pubspec.yaml: - Import the package in your Dart code:
Always check that you're using the latest version of the package on pub.dev to benefit from new features.
Initialize the SDK
Before sending events, initialize the Weespin client and device information:
The userId parameter is optional but recommended to link events to a specific user across sessions.
Send a custom event
Use the logEvent method to track user actions with custom data:
You can then trigger this from any UI action:
Update user identifier
You can change the user ID at any time, useful after login or signup:
Use case: Call setUserId after a successful login to associate all subsequent events with the authenticated user.
Event payload rules
Requirements:
eventNamemust be a non-empty string.payloadmust be a JSON-compatible map.
Supported types:
Stringintdoublebool
Example payload:
Common event names:
add_to_cart- User adds a product to cartpurchase- User completes a transactionsignup- New user registrationlogin- User authenticationshare_link- User shares contentopen_app- App launch
Security notice: Never send sensitive personal data (passwords, credit card numbers, social security numbers) in event payloads.
Example usage in Flutter
Test your events
Dashboard: Check your Weespin dashboard to see events in real-time.
Testing tips:
- Test events on both iOS and Android devices.
- Verify event names match your analytics naming conventions.
- Check that all payload data appears correctly in the dashboard.
Conclusion / Best Practices
By integrating event tracking with Weespin:
- You gain valuable insights into user behavior.
- You can measure the effectiveness of your features.
- You optimize conversion funnels based on real data.
Recommendations:
- Send events after important user actions.
- Use consistent naming conventions (snake_case).
- Include contextual data (screen, platform, user_segment).
- Avoid over-tracking to keep data meaningful.