Skip to content

SDK Integration Overview

!!! info "TL;DR" Embed Canviq surveys in your app or website using the JavaScript SDK. Initialize it with your API key, and it shows the right survey automatically based on your trigger and targeting settings. Native SDKs for other platforms are in development.

Supported Platforms

Platform Package Status
JavaScript CDN bundle (script tag) ✅ Stable
React @canviq/sdk-react 🔜 Coming Soon
iOS (Swift) CanviqSDK (private beta) ✅ Stable
Android (Kotlin) com.canviq:sdk-android 🔜 Coming Soon
React Native @canviq/sdk-react-native 🔜 Coming Soon
Flutter canviq_sdk 🔜 Coming Soon
Vue @canviq/sdk-vue 🔜 Coming Soon
Angular @canviq/sdk-angular 🔜 Coming Soon

Recommended integration path: Use the JavaScript SDK for all web integrations while native SDKs are in development. It supports any web framework via a single script tag.

Core Capabilities

The JavaScript SDK:

  1. Checks eligibility and shows the survey: one call asks the server whether there's a published survey this visitor should see, and renders it if so
  2. Targeting and triggers: which survey (if any) shows is decided by the survey's trigger and targeting settings on the server, not by SDK code you write
  3. Event tracking: send named events with properties, batched and flushed automatically
  4. User identification: associate subsequent events with a user ID (kept in memory only, never persisted to localStorage)

Quick Start (JavaScript)

Initialization

Add the CDN script tag (copy it with your real key from Admin Dashboard → Settings → API Keys, or from the PMF onboarding wizard). The tag must load synchronously (no async/defer) so it can auto-mount:

<script
  src="https://cdn.canviq.app/sdk/latest/survey.min.js"
  data-key="your-api-key"
></script>

This alone auto-initializes the SDK and checks eligibility on page load. No further code is needed for a Page View trigger.

For Manual or Event triggers, or to call track()/identify(), get a handle on the SDK from the Canviq global the script tag exposes:

<script
  src="https://cdn.canviq.app/sdk/latest/survey.min.js"
  data-key="your-api-key"
></script>
<script>
  const canviq = Canviq.CanviqSDK.init({ key: 'your-api-key' })
</script>

@revoir/survey-js npm package coming soon: once published, you'll be able to import { CanviqSDK } from '@revoir/survey-js' instead of loading the CDN bundle. It isn't published today, so use the script tag above.

Checking Eligibility Manually

This is what the survey's Manual trigger type is for: call it yourself instead of relying on the tag's automatic check.

await canviq.checkAndShow()

If the visitor is eligible for a published survey with a matching trigger, it renders as a modal or slide-out; otherwise this is a no-op.

Tracking Events

For surveys configured with an Event trigger, send the event by name:

document.getElementById('export-button').addEventListener('click', () => {
  canviq.track('export_clicked', { format: 'pdf' })
})

Events are batched client-side and sent in the background.

User Identification

// Associate subsequent track() calls with a user
canviq.identify('user-123')

Display Mode

Set how the survey renders when it's shown, at init time:

Canviq.CanviqSDK.init({
  key: 'your-api-key',
  mode: 'modal', // 'modal' | 'slide-out'
})

React

🔜 Coming Soon: The React SDK (@canviq/sdk-react) is not yet available. In the meantime, load the CDN script tag directly (for example, inject it once from a top-level useEffect).

iOS (Swift)

The iOS SDK (CanviqSDK) is in private beta while Canviq is in pre-launch. Email support@canviq.app for access. Once granted, it installs via Swift Package Manager (File > Add Package Dependencies) or CocoaPods as normal, and the getting-started, API reference, and troubleshooting guides ship with that access. Requires iOS 15+, Swift 5.9+, Xcode 15+.

Initialization (call once at app launch, before any screens appear):

import CanviqSDK

CanviqSDK.shared.initialize(
    apiKey: "cvq_live_your_key_here",
    userId: currentUser?.id
)

Tracking events (surveys are shown automatically when trigger conditions match):

CanviqSDK.shared.track("completed_onboarding")

Android (Kotlin)

🔜 Coming Soon: The Android SDK (com.canviq:sdk-android) is not yet available. The Gradle artifact is not published.

React Native

🔜 Coming Soon: The React Native SDK (@canviq/sdk-react-native) is not yet available.

Flutter

🔜 Coming Soon: The Flutter SDK (canviq_sdk) is not yet available.

Detailed Platform Guides

iOS's getting-started, API reference, and troubleshooting guides live in the iOS SDK repo, which is private while Canviq is in pre-launch. Email support@canviq.app for access.

Android, React Native, Flutter, React, Vue, and Angular guides will be published when each SDK ships.

Troubleshooting

Survey Not Appearing

  1. Check API Key: Verify your API key is correct in the SDK initialization
  2. Check Survey Status: Ensure the survey is published (not in draft mode)
  3. Check Trigger Settings: Verify the survey has an enabled trigger that matches how you're calling the SDK (Event vs. Manual vs. Page View)
  4. Check Fatigue Rules: The visitor may have already seen too many surveys recently

Responses Not Saving

  1. Check Network: Ensure the device has internet connectivity
  2. Check API Key: Confirm the key belongs to the same organization as the survey

What's Next