SDK Integration Overview¶
!!! info "TL;DR" Embed Canviq surveys in your app or website using platform-specific SDKs. Supports JavaScript, React, iOS, Android, React Native, and Flutter. Initialize with your API key, trigger surveys based on user actions, and optionally associate responses with user IDs.
Supported Platforms¶
Canviq provides native SDKs for all major platforms:
| Platform | Package | Status |
|---|---|---|
| JavaScript | @canviq/sdk-js | ✅ Stable |
| React | @canviq/sdk-react | ✅ Stable |
| iOS (Swift) | CanviqSDK (CocoaPods, SPM) | ✅ Stable |
| Android (Kotlin) | com.canviq:sdk-android | ✅ Stable |
| React Native | @canviq/sdk-react-native | ✅ Stable |
| Flutter | canviq_sdk | ✅ Stable |
| Vue | @canviq/sdk-vue | 🚧 Beta |
| Angular | @canviq/sdk-angular | 🚧 Beta |
Each SDK is maintained in the Canviq SDK Monorepo using Turborepo and Changesets for versioned releases.
Core Capabilities¶
All SDKs provide:
- Survey Display — Show surveys as modals, slide-ins, or inline components
- Targeting — Control when and where surveys appear based on user behavior
- User Association — Link responses to user IDs for personalized follow-ups
- Offline Support — Queue responses locally and sync when online
- Localization — Automatic language detection or manual locale override
- Accessibility — Keyboard navigation, screen reader support, and WCAG compliance
Quick Start (JavaScript)¶
Installation¶
Initialization¶
import { CanviqSDK } from '@canviq/sdk-js'
CanviqSDK.init({
apiKey: 'your-api-key', // Required: Get from Admin → Settings → API Keys
userId: 'user-123', // Optional: Associate responses with a user
locale: 'en', // Optional: Force a specific locale (auto-detected by default)
debug: false, // Optional: Enable debug logging
})
Show a Survey¶
// Show immediately
CanviqSDK.showSurvey('survey-id')
// Show after a delay
CanviqSDK.showSurvey('survey-id', {
delay: 5000, // 5 seconds
})
// Show after a specific event
document.getElementById('export-button').addEventListener('click', () => {
CanviqSDK.showSurvey('survey-id', {
trigger: 'export_clicked',
metadata: { format: 'pdf', size: 'large' },
})
})
User Identification¶
// Identify user after login
CanviqSDK.identify('user-123', {
email: 'user@example.com',
name: 'Jane Doe',
role: 'premium',
signupDate: '2026-01-15',
})
// Update user properties
CanviqSDK.updateUser({
lastActiveDate: new Date().toISOString(),
featureUsageCount: 42,
})
// Clear user on logout
CanviqSDK.reset()
Widget Customization¶
CanviqSDK.showSurvey('survey-id', {
style: 'modal', // 'modal' | 'slide-in' | 'inline'
position: 'bottom-right', // For slide-in: 'bottom-right' | 'bottom-left' | 'top-right' | 'top-left'
zIndex: 9999, // CSS z-index for modal/slide-in
theme: 'dark', // 'light' | 'dark' | 'auto'
})
Quick Start (React)¶
Installation¶
Provider Setup¶
import { CanviqProvider } from '@canviq/sdk-react'
function App() {
return (
<CanviqProvider apiKey="your-api-key" userId="user-123" locale="en">
<YourApp />
</CanviqProvider>
)
}
Trigger Survey¶
import { useSurvey } from '@canviq/sdk-react'
function ExportButton() {
const { showSurvey } = useSurvey()
const handleExport = () => {
// Your export logic
showSurvey('survey-id', {
trigger: 'export_clicked',
metadata: { format: 'pdf' },
})
}
return <button onClick={handleExport}>Export PDF</button>
}
Inline Survey Component¶
import { Survey } from '@canviq/sdk-react'
function FeedbackPage() {
return (
<div>
<h1>We'd love your feedback</h1>
<Survey surveyId="survey-id" style="inline" />
</div>
)
}
Quick Start (iOS)¶
Installation (CocoaPods)¶
Initialization¶
import CanviqSDK
CanviqSDK.shared.initialize(
apiKey: "your-api-key",
userId: "user-123",
locale: "en"
)
Show Survey¶
// Show immediately
CanviqSDK.shared.showSurvey(surveyId: "survey-id")
// Show after user action
@IBAction func exportButtonTapped(_ sender: UIButton) {
CanviqSDK.shared.showSurvey(
surveyId: "survey-id",
trigger: "export_clicked",
metadata: ["format": "pdf"]
)
}
User Identification¶
// Identify user after login
CanviqSDK.shared.identify(
userId: "user-123",
properties: [
"email": "user@example.com",
"name": "Jane Doe",
"role": "premium"
]
)
// Clear user on logout
CanviqSDK.shared.reset()
Quick Start (Android)¶
Installation (Gradle)¶
Initialization¶
import com.canviq.sdk.CanviqSDK
CanviqSDK.initialize(
context = applicationContext,
apiKey = "your-api-key",
userId = "user-123",
locale = "en"
)
Show Survey¶
// Show immediately
CanviqSDK.showSurvey(surveyId = "survey-id")
// Show after user action
exportButton.setOnClickListener {
CanviqSDK.showSurvey(
surveyId = "survey-id",
trigger = "export_clicked",
metadata = mapOf("format" to "pdf")
)
}
User Identification¶
// Identify user after login
CanviqSDK.identify(
userId = "user-123",
properties = mapOf(
"email" to "user@example.com",
"name" to "Jane Doe",
"role" to "premium"
)
)
// Clear user on logout
CanviqSDK.reset()
Detailed Platform Guides¶
For full integration guides, see:
- JavaScript SDK Documentation
- React SDK Documentation
- iOS SDK Documentation
- Android SDK Documentation
- React Native SDK Documentation
- Flutter SDK Documentation
Common Patterns¶
Post-Purchase Survey¶
// After successful checkout
CanviqSDK.showSurvey('post-purchase-survey', {
delay: 10000, // Wait 10 seconds
metadata: {
orderId: '12345',
total: 99.99,
items: 3,
},
})
Feature Usage Survey¶
// After user exports a file
CanviqSDK.showSurvey('export-feedback', {
trigger: 'export_completed',
metadata: { format: 'pdf', fileSize: '5MB' },
maxShownCount: 1, // Only show once per user
})
Churn Prevention Survey¶
// Show to users who haven't logged in for 14 days
if (daysSinceLastLogin > 14) {
CanviqSDK.showSurvey('churn-prevention', {
style: 'modal',
dismissable: false, // Force interaction
})
}
Troubleshooting¶
Survey Not Appearing¶
- Check API Key — Verify your API key is correct in the SDK initialization
- Check Survey Status — Ensure the survey is published (not in draft mode)
- Check Targeting Rules — Verify the user meets targeting criteria
- Check Fatigue Rules — User may have already seen too many surveys recently
- Check Console — Enable debug mode and check browser/app console for errors
Responses Not Saving¶
- Check Network — Ensure the device has internet connectivity (or wait for offline sync)
- Check API Key Permissions — Verify your API key has
survey:response:writescope - Check User ID — If required, ensure a valid user ID was provided
Localization Issues¶
- Check Locale Code — Ensure locale is in BCP 47 format (e.g.,
en,es,pt-BR) - Check Survey Translations — Verify the survey has translations for the target locale
- Check Auto-Detection — If not manually set, SDK uses browser/device language
What's Next¶
- Creating Surveys — Build your first survey
- Distribution — Learn about targeting and fatigue management
- Analytics — Track survey performance and sentiment