Skip to main content

Overview

The Permutive JavaScript SDK enables user segmentation, personalization, and ad targeting on your website. Track user behavior, manage identities, and deliver targeted advertising through integrations with major ad platforms including Google Ad Manager, Prebid.js, and Xandr. Current Version: See your Permutive dashboard for the latest version.
Browser Support: The SDK supports all modern browsers including Chrome, Firefox, Safari, and Edge. It is designed to work in environments without third-party cookies.

Getting Started

New to the Permutive JavaScript SDK? Start here.

Core Concepts

Understand the fundamental concepts of the Permutive SDK.

Features

Detailed guides for specific SDK features.

Integrations

Connect Permutive with ad platforms and header bidding solutions.

Common Tasks

The web addon automatically tracks pageviews when configured. You can also include custom page properties.
permutive.addon('web', {
  page: {
    type: 'article',
    article: {
      title: 'Breaking News: Tech Advances',
      categories: ['technology', 'news'],
      authors: ['Jane Smith'],
      publishedAt: '2024-01-15'
    }
  }
});
permutive.track('Purchase', {
  product_id: 'SKU123',
  product_name: 'Premium Subscription',
  price: 9.99,
  currency: 'USD'
});
// Simple identity
permutive.identify([
  { tag: 'email_sha256', id: 'a1b2c3d4e5f6...' },
  { tag: 'internal_id', id: 'user_12345', priority: 1 }
]);
// Check if user is in a specific cohort
permutive.segment(12345, function(inCohort) {
  if (inCohort) {
    showPremiumContent();
  }
});

// Get all cohorts
permutive.segments(function(segments) {
  console.log('User cohorts:', segments);
});
// Using the DFP addon (automatically sets targeting)
permutive.addon('web', { page: { /* ... */ } });

// Or manually get segments for GPT
permutive.segments(function(segments) {
  googletag.cmd.push(function() {
    googletag.pubads().setTargeting('permutive', segments);
  });
}, 'dfp');

Key API Methods

MethodPurpose
permutive.track(event, properties)Track custom events
permutive.identify(identities)Set user identities
permutive.trigger(code, param, handler)React to cohort entry/exit
permutive.segment(code, handler)Check single cohort membership
permutive.segments(handler, type)Get all cohorts
permutive.query(code, handler)Reserved for future use
permutive.ready(callback, stage)Wait for SDK initialization
permutive.consent(data)Set consent status
permutive.addon(name, options)Initialize addons
permutive.on(event, callback)Persistent event listener
permutive.once(event, callback)Single event listener
permutive.reset()Clear user data

Requirements

RequirementDetails
BrowsersModern browsers (Chrome, Firefox, Safari, Edge)
JavaScriptES5+ (SDK is transpiled for compatibility)
CookiesFirst-party cookies required for identity persistence
localStorageRequired for cohort storage

Installation

Key Concepts

The SDK uses a queue-based loading pattern. Methods called before the SDK loads are queued and executed in order once the SDK initializes. This means you can safely call SDK methods immediately without waiting for load.
  • Cohorts: All segments a user belongs to
  • Activations: Cohorts configured for specific ad platforms (e.g., dfp for Google Ad Manager)
  • Behavioral: Based on user history (e.g., “sports enthusiast”)
  • Contextual: Based on current page content (e.g., viewing sports article right now)
The web addon provides automatic tracking for pageviews, engagement time, form submissions, and link clicks. It’s the recommended way to track user activity.

Additional Resources

FAQ

Yes. The Permutive SDK uses first-party cookies and localStorage, which are not affected by third-party cookie restrictions. It works effectively in Safari, Firefox, and other browsers that block third-party cookies.
Add ?permutive_debug=true to any page URL to enable debug logging in the browser console. You’ll see detailed information about events, cohorts, and SDK activity.
The web addon automatically tracks standard events (Pageview, PageviewEngagement, FormSubmission, LinkClick) with minimal configuration. Use track() for custom events that don’t fit these patterns.
Yes. The web addon provides a reset() method for SPA navigation. Call it when the route changes to track new pageviews. See Pageview Tracking for details.

Getting Help

Privacy & Compliance

Permutive is designed with privacy in mind: GDPR compliant, CCPA compliant, no PII storage, user consent respected, and transparent data usage.