Next Commerce

Getting Started

Start or continue a campaign, preview locally, and connect products, offers, domains, analytics and hosting

Campaigns are custom checkout funnels (landing, checkout, upsell, and receipt pages) backed by a CORS-enabled API for products, pricing, payments, and orders. No backend integration required.

Campaign orders are regular store orders. They appear in the store's Orders list, the Admin API, and webhooks.

Campaigns OS Start

Give an agent a funnel URL, repo, or saved Map with the campaign agent guide. It can plan and prepare a local concept before you have store access. The Campaigns OS Start guide covers the Workspace/Map route. You can keep your existing builder and host.

To scaffold a project yourself, use the Campaign Page Kit: a CLI that creates an SDK-ready starter, runs a hot-reload dev server, and builds a static site for any static host.

Quick Start

1. Prerequisites

  • Node.js 18+ for Page Kit alone. If using Campaigns OS too, follow its runtime guidance; Node.js 22 is a common supported choice.
  • To connect commerce: a Next Commerce store with a campaign created in the Campaigns App
  • To connect commerce: your Campaign API key: select Developer in the campaign header to open the Developer workspace, then copy the key from the Campaigns API section

2. Initialize a new project

In a fresh directory:

mkdir my-campaigns && cd my-campaigns
npm init -y
npm install next-campaign-page-kit
npx campaign-init

campaign-init runs these steps:

  1. Pick a starter template (see Starter templates below)
  2. Enter your campaign name and slug (the URL path, e.g. /my-campaign/)
  3. The template is downloaded into src/<slug>/ and registered in _data/campaigns.json
  4. CLI scripts (dev, build, clone, config, compress) are added to your package.json
  5. Optionally, your API key is written to assets/config.js
  6. Optionally, an AI context doc is installed for Claude Code, Cursor, Codex, or Copilot

AI-ready out of the box

The --ai-context step writes your assistant's context file: CLAUDE.md, AGENTS.md, .cursor/rules/, or .github/copilot-instructions.md. It covers the project structure, Liquid filters, and SDK conventions.

Without an API key, the scaffold runs against the starter templates' demo campaign and store. Run npm run config to connect your campaign before testing.

3. Start the dev server

npm run dev

This opens your campaign's first page (e.g. /<slug>/presell/) and hot-reloads as you edit. With several campaigns in the project, you pick one first.

๐ŸŽ‰ You did it!

Checkout still depends on the right campaign binding, packages, offers, and allowed domain. A local build doesn't verify them.

4. Place a test order

Run the funnel on your dev server with the card below. It skips the real payment, but still creates a test order that can trigger downstream integrations.

Card numberExpiryCVVWhat it does
6011 1111 1111 1117Any future dateAnyTest payment success flow without transaction

Testing covers 3DS, decline, and subscription test cards, the Test Gateway, and safe QA on live stores.

What you got

Each campaign has its own layouts, assets, and config, so one repo can hold several campaigns.

my-campaigns/
โ”œโ”€โ”€ _data/
โ”‚   โ””โ”€โ”€ campaigns.json          # Registry โ€” all campaigns live here
โ”œโ”€โ”€ src/
โ”‚   โ””โ”€โ”€ <slug>/                 # Your campaign
โ”‚       โ”œโ”€โ”€ _layouts/base.html  # Page wrapper
โ”‚       โ”œโ”€โ”€ _includes/          # Reusable components
โ”‚       โ”œโ”€โ”€ assets/
โ”‚       โ”‚   โ”œโ”€โ”€ css/
โ”‚       โ”‚   โ”œโ”€โ”€ images/
โ”‚       โ”‚   โ”œโ”€โ”€ js/
โ”‚       โ”‚   โ””โ”€โ”€ config.js       # SDK config โ€” API key lives here
โ”‚       โ”œโ”€โ”€ presell.html
โ”‚       โ”œโ”€โ”€ checkout.html
โ”‚       โ”œโ”€โ”€ upsell.html
โ”‚       โ””โ”€โ”€ receipt.html
โ””โ”€โ”€ package.json

Starter templates

Each template ships SDK-ready checkout, upsell, and receipt pages, plus presell and landing pages. Replace its copy, assets, package IDs, offer codes, shipping methods, tracking, and routes with your campaign's values. Use Apollo for a standard tiered checkout, or Apollo MV for configurable variant slots (catalog). Keep an existing family when it fits the project.

apollo preview

apollo

Single-step checkout with a direct-response layout, include-driven bundle selector with interchangeable card styles, and optional checkout reveal.

apollo-mv-single-step preview

apollo-mv-single-step

Apollo layout for products with variants โ€” configurable multi-variant bundle slots on a single-step checkout.

See all available templates โ†’

Campaign Flow

A typical campaign funnel:

PresellAdvertorialLandingMarketingCheckoutOrder FormUpsellPost-PurchaseReceiptConfirmation
  • Presell: advertorial that warms up cold traffic before the offer
  • Landing: marketing page that drives traffic
  • Checkout: package selection, shipping, payment
  • Upsells: post-purchase offers
  • Receipt: order confirmation

Add, remove, or reorder pages, or run several funnels for different audiences. Each page's next_page parameter sets the page after it.


Cart SDK

The Campaign Cart SDK runs these pages. Its docs are versioned with each release on their own site.

cart-sdk.nextcommerce.com โ†’

ReferenceWhat it covers
Getting startedLoading the SDK and configuring it
Migrating from 0.4.xWhat changed for pages built on 0.4.x: removed, deprecated, unchanged
Data attributesEvery data-next-* attribute
JavaScript APIThe window.next methods
EventsEvery next.on event and its payload
Analytics eventsEvery tracking event and its payload
URL parametersParameters the SDK reads at boot
Loader scriptAttributes the loader script reads (data-campaign, data-funnel)
DebuggerThe ?debug=1 debug panel

Building a specific funnel page:

PageWhat it covers
Landing and presellSelectors, bundles, add to cart
Checkout pageForm fields, payment, express checkout
Upsell pageAccept and decline flows
Receipt pageOrder data rendering

Use the site's version selector to match the SDK version your campaign loads. Campaigns on 0.4.x keep working; see the 0.4.43 docs and Migrating from 0.4.x before moving to 0.5.


Concepts

Campaigns

A campaign bundles everything needed for a checkout: packages, offers, shipping options, payment methods, and localization. Each campaign has a unique API key used by the SDK to authenticate requests.

A campaign serves one language at a time, so another language needs its own campaign. The default currency can't change after create. The API key is safe in browser code; the authorized domains limit where it works.

Packages

A package is the campaign's sellable reference to a product or product variant. In SDK 0.4.x-compatible builds, keep packages to identity and base price:

  • Keep one package per product or variant customers can buy. In Campaigns App, selecting a store product in an offer creates its package (one per variant, at the store price), and later offers reuse it. Use Add Products on the campaign's Products tab for a product no offer discounts.
  • Use the package's base list price as the anchor price.
  • Send the selected package ID and quantity from the page.
  • Discount quantity tiers with offers, and upsells, downsells, and exit pops with Code offers.

Don't bake bundle discounts (e.g. "buy 3 for $21") into separate packages. Offers keep the package list stable and let the API return before/after pricing for savings displays.

Package Quantity and Retail Price are legacy fields. They appear when the campaign setting Enable Package Retail Price & Quantity is on. New builds use offers instead.

Packages can also be recurring for subscription products. In HTML (data-next-package-id="โ€ฆ"), use the ID shown on the product's row in the campaign's Products tab.

Offers

An offer discounts the order when it meets a condition.

  • Offer: applies automatically at checkout.
  • Code: applies when the customer enters it. Upsell pages use codes, since automatic offers don't run there.

One automatic offer applies per benefit type. The winner has the largest quantity, then count_equal, then the largest order_value minimum, then the largest discount.

Codes stack on automatic offers. A 10% code on a line already 50% off charges 45% of the original price.

Package benefits apply first, then order, then shipping.

Every offer has a condition that decides when it applies and a benefit that decides what it discounts.

Condition types

TypeApplies whenExample
anyAlways. No quantity requirement.A code that takes 10% off any cart
countThe quantity of a matching package is at or above valueBuy 2 or more Widgets
count_equalThe quantity of a matching package is exactly valueExactly 2 Widgets
order_valueThe order value after every package, order, and code discount, before shipping, is at or above the currency's minimumFree shipping on orders of $50 or more

An order_value condition sets a minimum per campaign currency in minimum_values instead of a value, and always covers every package. The Cart API returns the minimum for the requested currency as minimum_value.

Other conditions target package_ids or all_packages: true (every package, including ones added later): the dashboard's Products or All Products. Use package_ids for tier offers, since all_packages also discounts full-price add-ons.

Benefit types

All benefits are percentage based. value is the percentage off.

TypeDiscountsExample
package_percentageThe unit price of each package matched by the condition30% off each Widget when buying 2 or more
shipping_percentageThe shipping price50% off shipping when buying 3 or more
order_percentageThe entire order10% off everything with a welcome code

An order_value condition can't take a package_percentage benefit. Use order_percentage or shipping_percentage.

A benefit can also set price_rounding so each discounted unit price ends in .00, .95, .97, or .99. Without it, the discounted price is floored to the cent. Rounding never raises a price above its price before the offer.

Create and manage offers with the Campaigns Admin API. The Cart API returns the same condition and benefit fields on each offer from campaignRetrieve.

Example: quantity tier pricing

One Widget package at $49.95/unit, with one offer per quantity tier, including 1x:

QuantityList priceOfferCustomer paysSavings
1x$49.95Buy 1 โ†’ $39.95 (Save 20%)$39.95$10.00
2x$99.90Buy 2 โ†’ $34.95 each (Save 30%)$69.90$30.00
3x$149.85Buy 3 โ†’ $29.95 each (Save 40%)$89.85$60.00

Each tier is a count condition on the Widget package with a package_percentage benefit. The list price stays at $49.95/unit.

Shipping methods

A campaign shipping method links to a store shipping method with its own campaign price, such as a flat $4.95 or free shipping. The store's shipping method doesn't change.

For conditional shipping discounts, such as free shipping at 3 or more or on orders of $50 or more, use a shipping_percentage offer instead of a second shipping method.

Domains

Allowed domains control where your campaign API keys work. Set them in the Campaigns app under Settings, then Allowed Domains. They apply to all campaigns.

TypeSDK AccessNEXT campaign analytics
ProductionYesYes, events recorded automatically
DevelopmentYesNo, events ignored

The environment setting controls NEXT's own campaign analytics only. Vendor pixels and the SDK's event stream still run on development domains. See Test and troubleshoot tracking.

Add localhost and any staging domains as development domains to test checkout without adding sessions to NEXT campaign analytics.

Requests from unlisted domains are rejected. Add every domain your SDK runs on.


Analytics & Tracking

NEXT Campaign Analytics is on by default in every starter template. The SDK tracks the full funnel (page views, add-to-cart, begin checkout, shipping and payment info, purchase, and upsells) for NEXT's campaign reports, with no code.

To send those events to your ad and analytics platforms, see Tracking.

Keep your campaign analytics clean

Two things keep test traffic out of NEXT's campaign reports:

  • Development domains: visits from them are ignored. Add localhost, staging URLs, and preview hosts.
  • ?ignore=true: add it to any link to turn tracking off for that browser tab. Turn it back on with ?ignore=false.

Do not use ?ignore=true when you are checking that a purchase is reported. See Test and troubleshoot tracking.


Non-interactive setup (agents, CI)

campaign-init runs without prompts when you pass every value as a flag. This example uses apollo, a single-step checkout; pick the family from the template catalog. CAMPAIGN_API_KEY is the campaign's browser-visible Campaign Cart key, never an Admin API token.

npx campaign-init --non-interactive \
    --template apollo \
    --slug my-campaign \
    --name "My Campaign" \
    --api-key "${CAMPAIGN_API_KEY:?set CAMPAIGN_API_KEY first}" \
    --ai-context claude

Add --json for machine-readable stdout. See the page-kit CLI reference for the full flag list and exit codes.


Hosting

npm run build outputs a static site to _site/ that runs on any static host. Configure your provider with:

  • Build command: npm run build
  • Publish directory: _site

Add the host's domain (e.g. *.netlify.app or your custom domain) to your allowed domains.

Netlify

Netlify auto-detects the build command from your Git repo and serves _site/ on a *.netlify.app subdomain.

Cloudflare Pages

Cloudflare Pages: connect your Git repo, set the framework preset to "None", the build command to npm run build, and the output directory to _site.

Render

Render: create a Static Site from your repo with publish path _site.

Other static hosts

The same _site/ output works on Vercel, GitHub Pages, AWS S3 + CloudFront, Surge, or any host that serves static files.

On this page