Next Commerce

Configuration

The SDK is configured via window.nextConfig before the SDK script loads, and via meta tags in your HTML <head>.

Replace your-api-key-here with your actual Campaign API key from the dashboard.

JavaScript Configuration

Minimal Setup

// Configure before SDK loads
window.dataLayer = window.dataLayer || [];
window.nextReady = window.nextReady || [];

window.nextConfig = {
  apiKey: "your-api-key-here"
};

Full Configuration Reference

window.nextConfig = {
  // Required: Your Campaign Cart API key
  apiKey: "your-api-key-here",

  // Currency behavior when country changes
  currencyBehavior: 'auto', // 'auto' | 'manual'

  // Payment and checkout configuration
  paymentConfig: {
    expressCheckout: {
      enabled: true,
      requireValidation: false, // Require form validation before express checkout
      requiredFields: ['email', 'fname', 'lname'],
      methodOrder: ['paypal', 'apple_pay', 'google_pay']
    }
  },

  // Address and country configuration
  addressConfig: {
    defaultCountry: "US",
    showCountries: ["US", "CA", "GB", "AU", "DE", "FR"],
    dontShowStates: ["AS", "GU", "PR", "VI"],
    enableAutocomplete: true, // NEXT Address Autocomplete
  },

  // Google Maps integration (address autocomplete)
  googleMaps: {
    apiKey: "your-google-maps-api-key",
    region: "US",
    enableAutocomplete: false 
  },

  // Analytics providers
  analytics: {
    enabled: true,
    mode: 'auto', // 'auto' | 'manual' | 'disabled'
    providers: {
      nextCampaign: {
        enabled: true
      },
      gtm: {
        enabled: false,
        settings: {
          containerId: "GTM-XXXXXX",
          dataLayerName: "dataLayer"
        },
      },
      facebook: {
        enabled: false,
        settings: {
          pixelId: "YOUR_PIXEL_ID"
        },
      },
      rudderstack: {
        enabled: false,
        settings: {},
      },
      custom: {
        enabled: false,
        settings: {
          endpoint: "https://your-analytics.com/track",
          apiKey: "your-api-key"
        }
      }
    }
  },

  // UTM parameter transfer (preserve tracking params across pages)
  utmTransfer: {
    enabled: true,
    applyToExternalLinks: false,
    debug: false,
    // Optional: excludedDomains: ['example.com'],
    // Optional: paramsToCopy: ['utm_source', 'utm_medium', 'utm_campaign', 'gclid', 'fbclid']
  }
};

Meta Tag Configuration

Configure the SDK on a per-page basis using meta tags in your HTML <head>:

<!-- Campaign API Key: Optional override -->
<meta name="next-api-key" content="your-api-key-here">

<!-- Funnel Name -->
<meta name="next-funnel" content="Example Funnel">

<!-- Page Type: product, checkout, upsell, or receipt -->
<meta name="next-page-type" content="product">

<!-- Next URL: Redirect after order completion (checkout pages) -->
<meta name="next-success-url" content="/upsell">

<!-- Prevent Back Navigation: Usually on first upsell page -->
<meta name="next-prevent-back-navigation" content="true">

<!-- Upsell URLs: For upsell pages -->
<meta name="next-upsell-accept-url" content="/receipt">
<meta name="next-upsell-decline-url" content="/receipt">

On this page