Skip to content

Installation

Campaign Cart JS SDK can be installed in multiple ways to fit your development workflow. Choose the method that works best for your project.

The fastest way to get started is with our CDN:

  1. Get Your API Key

    Go to Next Commerce Dashboard, open the Campaigns app, select your campaign, click on Integration, and copy your API key.

    Getting your API key from the Campaign Integration dialog
  2. Add SDK Script

    Add these two lines to your HTML <head> section:

    HTML Head Section
    <!-- Campaign Cart Configuration -->
    <meta name="next-api-key" content="your-api-key-here">
    <!-- Campaign Cart SDK -->
    <script src="https://cdn.jsdelivr.net/gh/NextCommerceCo/[email protected]/dist/loader.js" type="module"></script>
  3. Start Building

    You can now use Campaign Cart attributes in your HTML!

<!-- Campaign Cart SDK -->
<script src="https://cdn.jsdelivr.net/gh/NextCommerceCo/[email protected]/dist/loader.js" type="module"></script>
<!-- With integrity check (recommended for production) -->
<script
src="https://cdn.jsdelivr.net/gh/NextCommerceCo/[email protected]/dist/loader.js"
type="module"
integrity="sha384-..."
crossorigin="anonymous">
</script>

Configure the SDK using meta tags in your HTML head:

Meta Tag Configuration
<!-- Required: Your API key -->
<meta name="next-api-key" content="your-api-key">
<!-- Optional: Page type for analytics -->
<meta name="next-page-type" content="product">
<!-- Optional: Enable debug mode -->
<meta name="next-debug" content="true">
<!-- Optional: Custom domain for API calls -->
<meta name="next-api-domain" content="api.yoursite.com">
<!-- Optional: Currency override -->
<meta name="next-currency" content="EUR">
<!-- Optional: Language/locale -->
<meta name="next-locale" content="en-US">

For more advanced configuration, use JavaScript:

JavaScript Configuration
// Configure before SDK loads
window.nextConfig = {
apiKey: 'your-api-key',
debug: true,
currency: 'USD',
locale: 'en-US',
apiDomain: 'api.yoursite.com',
features: {
analytics: true,
upsells: true,
exitIntent: false
}
};
// Or configure after initialization
document.addEventListener('next:initialized', function() {
next.configure({
debug: false,
autoTrack: true
});
});
Development Setup
<!-- Development with debug enabled -->
<meta name="next-api-key" content="dev_your-api-key">
<meta name="next-debug" content="true">
<meta name="next-env" content="development">
<script src="https://cdn.jsdelivr.net/gh/NextCommerceCo/[email protected]/dist/loader.js" type="module"></script>
Production Setup
<!-- Production with specific version -->
<meta name="next-api-key" content="live_your-api-key">
<meta name="next-env" content="production">
<script
src="https://cdn.jsdelivr.net/gh/NextCommerceCo/[email protected]/dist/loader.js"
type="module">
</script>
Staging Setup
<!-- Staging environment -->
<meta name="next-api-key" content="staging_your-api-key">
<meta name="next-debug" content="true">
<meta name="next-env" content="staging">
<script src="https://cdn.jsdelivr.net/gh/NextCommerceCo/[email protected]/dist/loader.js" type="module"></script>

Verify the SDK loaded correctly:

Installation Check
// Open browser console and run:
console.log(window.next ? 'SDK Loaded' : 'SDK Not Found');
// Check SDK version
if (window.next) {
console.log('SDK Version:', next.version);
}
// Check configuration
if (window.next) {
console.log('Config:', next.getConfig());
}

Enable debug mode to see detailed logs:

Debug Mode
<!-- Enable via meta tag -->
<meta name="next-debug" content="true">
<!-- Or enable via JavaScript -->
<script>
window.nextConfig = { debug: true };
</script>
<!-- Or enable after load -->
<script>
document.addEventListener('next:initialized', function() {
next.enableDebug();
});
</script>

SDK Not Loading

  • Check for JavaScript errors in console
  • Verify API key is correct
  • Ensure script URL is accessible

Attributes Not Working

  • Confirm SDK has initialized (next:initialized event)
  • Check element has correct data-next-* attributes
  • Verify package IDs exist in your campaign

Performance Issues

  • Load SDK asynchronously with async attribute
  • Consider loading SDK after critical page content
  • Use specific version URLs for better caching

Documentation

Browse our complete guides and API reference. View Docs →


Next: Create your first product page →