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
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
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:
Initialization Order
For optimal performance, follow this initialization order:1
Loader Script
The inline loader script runs first, creating the queue and stub methods.
2
Consent (if required)
If using
consentRequired: true, call permutive.consent() after obtaining user consent.3
Identify (if available)
If you have user identity (e.g., logged-in user), call
permutive.identify() early.4
Web Addon
Initialize the web addon to start tracking pageviews and engagement.
5
Other Addons
Initialize other addons (DFP, Prebid, etc.) after the web addon.
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:Next Steps
Verification
Verify your integration is working
Pageview Tracking
Customize pageview tracking