Skip to content

Integrations

These are recipes, not packages. Responsly does not ship plugins or destinations for analytics tools. The few lines below are the whole integration, and they work with any tool that has a track call.

There are two directions:

  • Out: send survey events (shown, completed, dismissed) to your analytics tool.
  • In: let the events and screens you already track start surveys.

Register a listener and pass each event on. The examples use snake_case event names, which every tool accepts. Firebase Analytics allows only letters, digits and underscores in event names.

import ResponslySDK
final class SurveyAnalytics: ResponslyListener {
func surveyShown(_ event: ResponslySurveyShownEvent) {
send("survey_shown", ["survey_id": event.survey.id, "survey_name": event.survey.name])
}
func surveyCompleted(_ event: ResponslySurveyCompletedEvent) {
send("survey_completed", ["survey_id": event.surveyId, "response_id": event.responseId])
}
func surveyDismissed(_ event: ResponslySurveyDismissedEvent) {
send("survey_dismissed", ["survey_id": event.surveyId])
}
private func send(_ name: String, _ properties: [String: Any]) {
// Keep the line for your tool:
analytics.track(name: name, properties: properties) // Segment
// amplitude.track(eventType: name, eventProperties: properties) // Amplitude
// Mixpanel.mainInstance().track(event: name, properties: properties as? Properties) // Mixpanel
// Analytics.logEvent(name, parameters: properties) // Firebase Analytics
}
}
// At app start, after initialize:
let surveyAnalyticsToken = Responsly.shared.addListener(SurveyAnalytics())

What to forward:

EventForward itWhy
surveyShownyesThe top of the funnel. Add trigger.type and trigger.name as properties if you compare triggers.
surveyCompletedyesresponseId lets you find the response in Responsly later.
surveyDismissedyesCompleted divided by shown is your response rate.
questionAnsweredwith careAnswers are personal data. See the note below.
surveyNotShownnoIt fires for every failed targeting check and would flood your analytics. Use it for debugging.
surveyErrorto your error reportingRare, and useful when it happens.

Most apps already have one helper that every track, screen and identify call goes through. Add the Responsly call there. From then on, any event the app tracks can be used as a survey trigger in the Mobile app tab, with no further app changes.

import ResponslySDK
enum AppAnalytics {
static func track(_ event: String, properties: [String: Any] = [:]) {
analytics.track(name: event, properties: properties) // your analytics SDK
Responsly.shared.track(event, properties: ResponslyValue.properties(from: properties))
}
static func screen(_ name: String) {
analytics.screen(title: name) // your analytics SDK
Responsly.shared.screen(name)
}
static func identify(userId: String, traits: [String: Any] = [:]) {
analytics.identify(userId: userId, traits: traits) // your analytics SDK
Responsly.shared.identify(userId: userId, traits: ResponslyValue.traits(from: traits))
}
static func reset() {
analytics.reset() // your analytics SDK
Responsly.shared.reset()
}
}

ResponslyValue.properties(from:) and ResponslyValue.traits(from:) convert a loosely typed dictionary. They keep strings, numbers, booleans and dates and skip everything else.

Things to keep in mind:

  • Nothing is uploaded. track and screen only count events and check triggers on the device, so forwarding every event costs no network traffic. See Privacy & data.
  • Use stable event names. The SDK keeps a count per event name. Names that contain IDs or other variable parts (viewed_product_8841) create a new counter each time. Put the variable part in a property.
  • Pass flat values. Properties and traits are strings, numbers, booleans and dates. Leave nested objects and arrays out of what you pass to Responsly.
  • Names must match exactly. A trigger uses the event name as the app sends it, including case. Copy names from your tracking plan.
  • Reset together. When your analytics tool is reset on logout, reset Responsly in the same place.

If you use React Navigation or Flutter’s Navigator, screens can be reported without a helper. See Automatic screen tracking.