Wingify Pulse Android SDK - Survey Feature
The Wingify Pulse Android SDK enables you to deliver in-app surveys directly inside your Android application. By integrating the SDK, you can collect targeted user feedback at critical moments in the user journey.
Key Features
- Event-based Triggers - Trigger surveys based on specific events in your app
- User Identification - Identify and track users to ensure proper survey targeting
- Personalization - Personalize surveys with user attributes
- Localization - Localize surveys by setting different languages
Requirements
| Requirement | Details |
|---|---|
| Android Version | Android 5.0 (API level 21) and above |
| 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. -
Confirm Minimum SDK
The SDK officially supports API level 21 and above.
Quick Start
Step 1: SDK Installation
Add the SDK dependency to your app/build.gradle:
dependencies {
implementation 'com.wingify:insights:2.1.1'
}Step 2: Initialize the SDK
Initialize the SDK in your Application class's onCreate() method.
Kotlin
import com.wingify.insights.WingifyInsights
import com.wingify.insights.exposed.IWingifyInitCallback
import com.wingify.insights.exposed.models.ClientConfiguration
class MyApplication : Application() {
override fun onCreate() {
super.onCreate()
val clientConfig = ClientConfiguration(
"your_account_id",
"your_sdk_key",
"user_id"
)
val callback = object : IWingifyInitCallback {
override fun wingifyInitSuccess(message: String) {
// SDK initialized successfully
// You can now trigger surveys
}
override fun wingifyInitFailed(message: String) {
// SDK initialization failed
// Check network connectivity
}
}
WingifyInsights.init(this, callback, clientConfig)
}
}Java
import com.wingify.insights.WingifyInsights;
import com.wingify.insights.exposed.IWingifyInitCallback;
import com.wingify.insights.exposed.models.ClientConfiguration;
public class MyApplication extends Application {
@Override
public void onCreate() {
super.onCreate();
ClientConfiguration clientConfig = new ClientConfiguration(
"your_account_id",
"your_sdk_key",
"user_id"
);
IWingifyInitCallback callback = new IWingifyInitCallback() {
@Override
public void wingifyInitSuccess(@NotNull String message) {
// SDK initialized successfully
// You can now trigger surveys
}
@Override
public void wingifyInitFailed(@NotNull String message) {
// SDK initialization failed
// Check network connectivity
}
};
WingifyInsights.init(this, callback, clientConfig);
}
}Step 3: Register Application Class
Ensure your Application class is registered in AndroidManifest.xml:
<application
android:name=".MyApplication"
... >
</application>Step 4: Trigger a Survey
Add a trigger event to display surveys at specific points in your app.
Kotlin
val sdkManager = WingifyInsights.getSurveySdkManager(context)
sdkManager.trackEvent("event_name")Java
SdkManager sdkManager = WingifyInsights.getSurveySdkManager(context);
sdkManager.trackEvent("event_name");Triggers and Event Properties
What are Triggers?
Triggers are events in your app (e.g., button presses, screen loads, checkout completion) that prompt a survey if configured in the Wingify dashboard.
Triggering Surveys
You can trigger surveys using the trackEvent method.
Basic Trigger
Kotlin
val sdkManager = WingifyInsights.getSurveySdkManager(context)
sdkManager.trackEvent("event_name")Java
SdkManager sdkManager = WingifyInsights.getSurveySdkManager(context);
sdkManager.trackEvent("event_name");Trigger with Event Properties
You can pass additional event properties when triggering a survey:
Kotlin
val sdkManager = WingifyInsights.getSurveySdkManager(context)
val properties = mapOf(
"product_id" to "SKU123",
"amount" to 99.99,
"category" to "electronics"
)
sdkManager.trackEvent("purchase_completed", properties)Java
SdkManager sdkManager = WingifyInsights.getSurveySdkManager(context);
Map<String, Object> properties = new HashMap<>();
properties.put("product_id", "SKU123");
properties.put("amount", 99.99);
properties.put("category", "electronics");
sdkManager.trackEvent("purchase_completed", properties);Trigger with Activity Reference
For better context when displaying surveys, you can pass an Activity reference:
Kotlin
val sdkManager = WingifyInsights.getSurveySdkManager(context)
sdkManager.trackEventWithActivity(this, "checkout_screen")Java
SdkManager sdkManager = WingifyInsights.getSurveySdkManager(context);
sdkManager.trackEventWithActivity(this, "checkout_screen");Trigger with Completion Callback
You can also receive a callback when the survey interaction is complete:
Kotlin
val sdkManager = WingifyInsights.getSurveySdkManager(context)
val properties = mapOf("screen" to "home")
sdkManager.trackEvent("home_screen_loaded", properties) { result ->
// Survey interaction completed
println("Survey completed with result: $result")
}Java
SdkManager sdkManager = WingifyInsights.getSurveySdkManager(context);
Map<String, Object> properties = new HashMap<>();
properties.put("screen", "home");
sdkManager.trackEvent("home_screen_loaded", properties, result -> {
// Survey interaction completed
System.out.println("Survey completed with result: " + result);
});Personalizing and Localizing Surveys
Setting User Properties
You can set profile attributes directly through WingifyInsights using setAttribute(). This method supports different value types:
| Type | Example |
|---|---|
| String | "active" |
| Number | 3 |
| Boolean | true |
| Date | Timestamp in milliseconds |
Kotlin
val attributes = mutableMapOf<String, Any>()
attributes["account_status"] = "active"
attributes["user_level"] = 3
attributes["user_email"] = "[email protected]"
attributes["user_name"] = "John Doe"
WingifyInsights.setAttribute(attributes)Java
Map<String, Object> attributes = new HashMap<>();
attributes.put("account_status", "active");
attributes.put("user_level", 3);
attributes.put("user_email", "[email protected]");
attributes.put("user_name", "John Doe");
WingifyInsights.setAttribute(attributes);Setting Date Attributes
For date values, use timestamp in milliseconds.
Kotlin
val attributes = mutableMapOf<String, Any>()
// Use System.currentTimeMillis() for current time
attributes["signup_date"] = System.currentTimeMillis()
// Or use a specific date in milliseconds
attributes["subscription_expiry"] = 1735689600000L // Example: Jan 1, 2025
WingifyInsights.setAttribute(attributes)Java
Map<String, Object> attributes = new HashMap<>();
// Use System.currentTimeMillis() for current time
attributes.put("signup_date", System.currentTimeMillis());
// Or use a specific date in milliseconds
attributes.put("subscription_expiry", 1735689600000L); // Example: Jan 1, 2025
WingifyInsights.setAttribute(attributes);
Note: Always use milliseconds for date values, not epoch seconds. You can convert a Date object usingdate.getTime()in Java ordate.timein Kotlin.
Setting Survey Language
To display surveys in the user's preferred language, set the survey language using an ISO 639-1 code.
Kotlin
WingifyInsights.getSurveySdkManager(context).setSurveyLanguage("en")Java
WingifyInsights.getSurveySdkManager(context).setSurveyLanguage("en");Common Language Codes:
| Code | Language |
|---|---|
en | English |
es | Spanish |
fr | French |
de | German |
ja | Japanese |
Why Set Survey Language?
- Improve user experience by displaying surveys in the user's native language
- Support better localization for global apps
API Reference
WingifyInsights
| Method | Description |
|---|---|
init(application, callback, config) | Initializes the Wingify SDK |
getSurveySdkManager(context) | Returns the SdkManager instance for survey operations |
setAttribute(extras) | Sets custom profile attributes for surveys |
SdkManager
| Method | Description |
|---|---|
trackEvent(trigger) | Triggers a survey by trigger name |
trackEvent(trigger, properties, listener) | Triggers a survey with completion callback |
trackEventWithActivity(activity, trigger) | Triggers a survey with activity reference |
setUserProperties(properties) | Sets multiple user properties |
setSurveyLanguage(languageCode) | Sets the preferred survey language |
ClientConfiguration
| Parameter | Type | Required | Description |
|---|---|---|---|
accountId | String | Yes | Your Wingify account ID |
appId | String | Yes | Your SDK key from Wingify dashboard |
userId | String | Yes | Unique identifier for the user |
FAQ and Troubleshooting
Survey not showing up?
- Ensure Wingify SDK is initialized successfully (check for
wingifyInitSuccesscallback) - Verify that the trigger name matches exactly what's configured in the Wingify dashboard
- Check that surveys are active and properly configured in the dashboard
Survey not showing on home screen or first app page?
This might be a race condition. The SDK may not be fully initialized before you trigger the survey.
Solution: Use the wingifyInitSuccess callback to trigger surveys after successful initialization.
override fun wingifyInitSuccess(message: String) {
// Safe to trigger surveys here
WingifyInsights.getSurveySdkManager(context).trackEvent("home_screen_loaded")
}How to create events?
-
Create in dashboard first:
Navigate toData360 → Events → Createand create an event with anevent_name -
Configure in Surveys:
Go toSurveys → Custom Triggersand configure the event -
Use in your app:
Use the sameevent_namein your app code to launch the Survey
Network connectivity issues?
- The SDK requires network connectivity for initialization
- If
wingifyInitFailedis called, check the device's network connection - Surveys are fetched from the server when triggered
Best Practices
| Practice | Description |
|---|---|
| Initialize early | Call WingifyInsights.init() in your Application class's onCreate() method |
| Wait for initialization | Always wait for the wingifyInitSuccess callback before triggering surveys |
| Set user attributes early | Configure user attributes before triggering surveys for better targeting |
Version Information
| Component | Version |
|---|---|
| SDK Version | 2.1.0 |
| Minimum Android SDK | 21 (Android 5.0) |