live.js script loads. Configuration options are passed in the loader script and control SDK behavior.
Basic Initialization
The standard initialization passes your credentials and optional configuration:Configuration Options
Pass configuration options as the fourth argument to the loader function:Available Options
| Option | Type | Default | Description |
|---|---|---|---|
consentRequired | boolean | false | When true, SDK waits for consent before tracking |
loggingEnabled | boolean | false | Enable console logging (also enabled via ?permutive_debug=true) |
cookieDomain | string | Current domain | Domain for the Permutive cookie |
requestTimeout | number | 5000 | API request timeout in milliseconds |
Consent-Required Mode
WhenconsentRequired: true, the SDK will not track any events until consent is granted:
Web Addon Configuration
The web addon is initialized separately and handles automatic tracking. Call it after the SDK loads:Web Addon Options
| Option | Type | Description |
|---|---|---|
page | object | Custom page properties to include in Pageview events |
page.type | string | Page type (e.g., ‘article’, ‘homepage’, ‘section’) |
page.article | object | Article-specific metadata |
page.video | object | Video-specific metadata |
eventInterval | number | Milliseconds between PageviewEngagement events (default: 5000) |
context | object | Override default context (title, URL, referrer) |
Page Property Examples
- Article Page
- Homepage
- Section Page
- Video Page
Waiting for SDK Ready
Usepermutive.ready() to execute code after the SDK initializes:
Ready Stages
Theready() method accepts an optional stage parameter:
| Stage | When Fires |
|---|---|
initialised | SDK has loaded and initialized (default) |
realtime | Real-time cohort data has been processed |
Initialization Order
For optimal performance, follow this initialization order:Consent (if required)
If using
consentRequired: true, call permutive.consent() after obtaining user consent.Identify (if available)
If you have user identity (e.g., logged-in user), call
permutive.identify() early.Example: Complete Initialization
Cookie Configuration
The SDK uses a first-party cookie to persist user identity. Configure the cookie domain for cross-subdomain tracking:Set
cookieDomain to your root domain (with leading dot) to track users across subdomains like www.example.com and blog.example.com.Environment Configuration
For testing environments, you may want different configurations:Troubleshooting Initialization
SDK not initializing
SDK not initializing
Problem: No console messages,
permutive.ready() callback never fires.Solutions:- Check that API key and workspace ID are correct
- Verify
live.jsis loading (check Network tab) - Look for errors in the console
- Ensure the loader script runs before
live.js
Events not tracking with consentRequired
Events not tracking with consentRequired
Problem: Events are called but nothing appears in dashboard.Cause:
consentRequired: true but consent() was not called.Solution: Call permutive.consent({ opt_in: true, token: '...' }) after obtaining user consent.Web addon not tracking pageviews
Web addon not tracking pageviews
Problem: SDK initializes but no Pageview events.Solutions:
- Verify
permutive.addon('web', {...})is called - Check that consent has been granted (if
consentRequired: true) - Enable debug mode to see detailed logging
ready() callback fires before data is available
ready() callback fires before data is available
Problem: Calling
segments() in ready() callback returns empty array.Solution: Use the 'realtime' stage: