-
Notifications
You must be signed in to change notification settings - Fork 3
Quickstart
Ahmed Abbas edited this page Apr 7, 2026
·
1 revision
A copy-paste-ready guide to get up and running with the Convert JavaScript SDK in minutes.
npm install --save @convertcom/js-sdkOr with Yarn:
yarn add @convertcom/js-sdkimport ConvertSDK from '@convertcom/js-sdk';See Installation for all import patterns (ESM, CommonJS, UMD).
import type {
ConvertInterface, ConvertConfig, ContextInterface, BucketedVariation
} from '@convertcom/js-sdk';
import ConvertSDK from '@convertcom/js-sdk';
const convertSDK: ConvertInterface = new ConvertSDK({
sdkKey: 'xxx'
} as ConvertConfig);
convertSDK.onReady().then(() => {
// Create a user context
const context: ContextInterface = convertSDK.createContext('user-unique-id', {
country: 'US',
language: 'en'
});
// Run a single experience
const variation: BucketedVariation = context.runExperience('experience-key');
console.log(variation);
// Track a conversion
context.trackConversion('goal-key', {
ruleData: {
action: 'buy'
},
conversionData: [
{ key: 'amount', value: 10.3 },
{ key: 'productsCount', value: 2 },
{ key: 'transactionId', value: 'transaction-unique-id' }
]
});
});-
new ConvertSDK({ sdkKey })fetches your project configuration from Convert's CDN. -
onReady()resolves when the configuration has been downloaded and the SDK is ready. -
createContext(userId, properties)creates a visitor session. TheuserIdis used for deterministic bucketing -- the same user always sees the same variation. -
runExperience(key)evaluates targeting rules and returns the bucketed variation. -
trackConversion(goalKey, attributes)sends a conversion event for the given goal.
- Installation -- all bundle formats, CDN loading, and import patterns
-
Initialization -- SDK Key vs. static config,
onReady()details - Configuration -- full SDK config options reference
- Code Examples -- complete examples for every SDK method
Copyrights © 2025 All Rights Reserved by Convert Insights, Inc.
Getting Started
JavaScript SDK
Core Concepts
- Experiences & Variations
- Feature Flags
- Bucketing Algorithm
- Rule Evaluation
- Segments
- Data Management
- Event System
- API Communication
How-To Guides
- Running Experiences
- Running Features
- Tracking Conversions
- Visitor Context
- Persistent DataStore
- Client-Side Experimentation
- Server-Side Experimentation
- Tracking Script → SDK
- Troubleshooting
Edge & Integrations
Contributing