Wingify Pulse Flutter SDK - Survey Feature
The Wingify Pulse Flutter SDK allows you to deliver in-app surveys seamlessly within your Flutter application. Wingify's survey integration enables you to collect targeted user feedback during critical moments in the user journey.
Key Features
- Event-based Triggers - Quickly embed surveys via configurable events
- User Identification - Identify and track users to avoid duplicate surveys
- Personalization - Personalize surveys using user attributes and event properties
- Localization - Localize surveys by setting preferred languages
Requirements
| Requirement | Details |
|---|---|
| Flutter | 2.0+ |
| iOS | 12.0+ |
| Android | API level 21+ (Android 5.0) |
| Wingify Dashboard | Access required to retrieve Account ID and SDK Key |
Getting Started
Before You Begin
-
Obtain Your API Key
Log in to the Wingify dashboard and navigate to:
Configuration > Websites and apps > Default mobile app > SDK
Retrieve your API key from this section. -
Setup Wingify Pulse
Ensure you have the Wingify Pulse SDK integrated into your Flutter project.
Quick Start
Step 1: Add Dependency
Open your pubspec.yaml file and add the following dependency:
dependencies:
wingify_insights_flutter_sdk: ^2.1.0Step 2: Install Package
Run the command:
flutter pub getStep 3: Import Wingify
Import Wingify in your Dart code:
import 'package:wingify_insights_flutter_sdk/wingify_insights_flutter_sdk.dart';Step 4: Native Configuration
Android Initialization
Initialize the Wingify SDK in your Application class (e.g., FlutterWingifyApp.kt):
import com.wingify.insights.WingifyInsights
import com.wingify.insights.exposed.IWingifyInitCallback
import com.wingify.insights.exposed.models.ClientConfiguration
class FlutterWingifyApp : Application() {
override fun onCreate() {
super.onCreate()
val configuration = ClientConfiguration(
"YOUR_ACCOUNT_ID",
"YOUR_SDK_KEY",
"USER_ID"
)
WingifyInsights.init(this, object : IWingifyInitCallback {
override fun wingifyInitSuccess(s: String) {
// Wingify initialized successfully
// Safe to trigger surveys now
}
override fun wingifyInitFailed(s: String) {
// Wingify initialization failed
}
}, configuration)
}
}Register your Application class in AndroidManifest.xml:
<application
android:name=".FlutterWingifyApp"
... >
</application>iOS Initialization
Initialize the Wingify SDK in your AppDelegate.swift:
import Wingify_Insights
@UIApplicationMain
class AppDelegate: FlutterAppDelegate {
override func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
) -> Bool {
Wingify.configure(
accountId: "YOUR_ACCOUNT_ID",
sdkKey: "YOUR_SDK_KEY",
userId: "USER_ID"
) { result in
switch result {
case .success(_):
print("Wingify launch Success")
case .failure(_):
print("Wingify launch Failure")
}
}
GeneratedPluginRegistrant.register(with: self)
return super.application(application, didFinishLaunchingWithOptions: launchOptions)
}
}Step 5: Trigger a Survey
WingifyFlutter.trackEvent("event_name");Configuration Parameters
ClientConfiguration
| Parameter | Type | Required | Description |
|---|---|---|---|
| accountId | String | Yes | Your Wingify account ID |
| sdkKey | String | Yes | Your SDK key from Wingify dashboard |
| userId | String | Yes | Unique identifier for the user |
Triggering Surveys
Surveys can be triggered based on events that occur in your application.
Basic Trigger
Add events to initiate surveys at key moments (e.g., button press or page load):
WingifyFlutter.trackEvent("purchase_completed");Trigger with Event Properties
Attach properties to a trigger for advanced targeting. You can pass a map of key-value pairs as properties:
WingifyFlutter.trackEvent("product_viewed", {
"product_category": "electronics",
"price_range": "high",
"product_id": "SKU123"
});More Examples
// Purchase completed
WingifyFlutter.trackEvent("purchase_completed", {
"amount": 99.99,
"currency": "USD",
"payment_method": "credit_card"
});
// Feature usage
WingifyFlutter.trackEvent("feature_used", {
"feature_name": "dark_mode",
"duration_seconds": 120
});
// Screen view
WingifyFlutter.trackEvent("screen_viewed", {
"screen_name": "checkout",
"previous_screen": "cart"
});These properties help segment and target users based on context, and they can be configured in the Wingify dashboard.
Setting User Attributes
Add user attributes for targeting specific cohorts.
Basic Usage
WingifyFlutter.setAttribute({
"user_type": "premium",
"plan": "annual",
"user_name": "John Doe",
"user_email": "[email protected]"
});Supported Attribute Types
| Type | Example |
|---|---|
| String | "premium" |
| Number | 99.99 |
| Boolean | true |
| Date | Timestamp in milliseconds |
Setting Date Attributes
For date attributes, use timestamp in milliseconds:
WingifyFlutter.setAttribute({
"signup_date": 1704067200000,
"subscription_expiry": 1735689600000
});Note: Always use milliseconds for date values, not epoch seconds.
Language Settings
Define the preferred survey language using ISO 639-1 codes.
WingifyFlutter.setSurveyLanguage("en");Common Language Codes:
| Code | Language |
|---|---|
| en | English |
| es | Spanish |
| fr | French |
| de | German |
| ja | Japanese |
API Reference
WingifyFlutter Methods
setAttribute(attributes)
Sets custom profile attributes for survey targeting. Use timestamp in milliseconds for date values.
WingifyFlutter.setAttribute({
"user_type": "premium",
"user_email": "[email protected]"
});setSurveyLanguage(languageCode)
Sets the preferred survey language using ISO 639-1 code.
WingifyFlutter.setSurveyLanguage("en");trackEvent(triggerName, eventProperties)
Launches a survey based on the event name. Event properties are optional.
WingifyFlutter.trackEvent("purchase_completed", {
"amount": 99.99
});Best Practices
| Practice | Description |
|---|---|
| Initialize early | Initialize the SDK in Application class (Android) or AppDelegate (iOS) |
| Wait for initialization | Ensure SDK is fully initialized before triggering surveys |
| Set attributes first | Configure user attributes before triggering surveys for better targeting |
| Use meaningful events | Use descriptive event names that match Wingify dashboard configuration |
Recommended Flow
// 1. Set user attributes first
WingifyFlutter.setAttribute({
"user_type": "premium",
"user_name": "John Doe",
"user_email": "[email protected]"
});
// 2. Set language (optional)
WingifyFlutter.setSurveyLanguage("en");
// 3. Then trigger events
WingifyFlutter.trackEvent("home_screen_loaded");FAQ and Troubleshooting
Survey not showing up?
- Check SDK Initialization: Ensure the SDK is correctly initialized in your Application class (Android) or AppDelegate (iOS) with the correct Account ID, SDK Key, and User ID
- Verify Event Name: Make sure the event name matches exactly with the Wingify dashboard configuration
- Check Targeting Rules: Verify that targeting rules in the Wingify dashboard are satisfied
Survey not appearing on app launch?
If you trigger an event on launch, ensure the SDK is fully initialized. You might need to add a slight delay or ensure attributes are set before tracking the event:
// Add a delay after initialization
Future.delayed(Duration(milliseconds: 500), () {
WingifyFlutter.trackEvent("app_launched");
});Switching users?
Re-initialize the SDK with the new user's credentials before tracking events for a new user session.
How to create triggers?
-
Create in dashboard first: Navigate to Data360 > Events > Create and create an event
-
Configure in Surveys: Go to Surveys > Custom Triggers and configure the event
-
Use in your app: Use the same event name in your Flutter code
Support
For additional support or questions:
- Documentation: https://developers.wingify.com/reference/mobile-insights-introduction
- Support Email: [email protected]
Version Information
| Component | Version |
|---|---|
| Flutter Package | wingify_insights_flutter_sdk ^2.1.0 |
| Native Android SDK | 2.1.0 |
| Native iOS SDK | 2.1.0 |
| Minimum iOS Version | 12.0 |
| Minimum Android SDK | 21 (Android 5.0) |