Launch offer for the first 500 accounts: $10K MTR free for 24 months + $100 credit →
    .io

    Surveys API & Presentation Guide

    See it in the demo — Create surveys & NPS scales (~60s)

    Survey Overview

    BillDog Surveys enables in-app and web-embeddable surveys triggered by user behavior, paywall events, or custom events. The SDK provides two display options: **Native SwiftUI/Compose rendering** (default) and a unified **WebView-based rendering mode** using the core React application bundle.

    Core SDK Functions

    The Survey SDK allows programmatic control over presentation, custom targeting variables, lifecycle callbacks, event trigger maps, and offline response buffering.

    Programmatic Presentation

    Load and display surveys dynamically at runtime using the present API, with support for custom properties.

    Event-Based Triggering

    Register event-trigger maps directly in the client so that surveys display automatically when specific actions occur.

    Offline Queue Syncing

    Saves survey responses locally if the user loses connectivity and automatically retries submission on reconnect.

    Gating and Access Control

    Restricts survey dismissal, blocks back-press actions, or enforces single-session entry using configurations.

    SDK API Integration

    Integrate the survey presenter and implement lifecycle delegates on iOS and Android:

    import BillDogFull
    
    // 1. Configure once globally (e.g. AppDelegate)
    let presenter = BillDog.getSurveyPresenter()
    presenter?.isEnabled = true
    
    // 2. Set up a presentation handler to listen to lifecycle events
    let handler = SurveyPresentationHandler(
        onPresent: { surveyId in
            print("Survey displayed: \(surveyId)")
        },
        onDismiss: { surveyId in
            print("Survey dismissed: \(surveyId)")
        },
        onComplete: { surveyId, result in
            print("Survey completed. Respondent ID: \(result.respondent_id)")
        },
        onError: { error in
            print("Survey failed: \(error.localizedDescription)")
        },
        onAnswerChanged: { answer in
            print("Answer updated for question: \(answer.question_id)")
        }
    )
    
    // 3. Manually present a survey
    presenter?.present(
        surveyId: "satisfaction_survey",
        from: currentViewController,
        handler: handler,
        customerId: "user_456",
        customVariables: ["source": "checkout_abandon"]
    )

    Event-Based Presentation Triggers

    You can associate surveys with specific analytic events. Once registered, the SDK will automatically trigger and present matching surveys when the designated event name is recorded.

    let presenter = BillDog.getSurveyPresenter()
    
    // Register survey to auto-launch on checkout abandonment
    presenter?.registerEventTrigger(
        surveyId: "feedback_survey", 
        eventNames: ["checkout_abandoned", "cart_cleared"]
    )
    
    // Log the event later; if user qualifies, survey displays automatically
    presenter?.registerEvent(name: "checkout_abandoned", from: self)

    Caching & Offline Resiliency

    To ensure zero loss of response data in low-connectivity areas, submissions are written to local persistent databases. Use prefetch to download configs ahead of time.

    let presenter = BillDog.getSurveyPresenter()
    
    // 1. Prefetch config (warmed in cache, ready for offline presentation)
    presenter?.prefetch(surveyId: "user_satisfaction_2026")
    
    // 2. Query completion state offline
    let hasFinished = presenter?.hasCompletedSurvey(surveyId: "user_satisfaction_2026") ?? false
    
    // 3. Retry queued offline response payloads manually
    presenter?.flushOfflineQueue()

    Was this page helpful?

    Or rate this page:

    We use cookies and process your data to provide our services. By continuing, you agree to our Terms and Privacy Policy.