RudderStack

Sends each tracking event to the page's rudderanalytics as the 0.4.x RudderStack provider did: the same page(), identify() and track() calls, event names and properties, so RudderStack destinations and warehouse tables built on 0.4.x keep working. Vendor docs: RudderStack ecommerce spec.

Config

Off by default. On:

CODE
<script>
  window.nextConfig = {
    analytics: {
      destinations: { rudderstack: { enabled: true } },
    },
  };
</script>

The 0.4.x analytics.providers.rudderstack.enabled: true turns it on too.

What loads

rudderstack-*.js (about 3 KB), only when it is on. The SDK never loads RudderStack: the page has its JavaScript SDK snippet, whose ready() the SDK waits for. Without rudderanalytics the SDK logs one warning and sends nothing.

Events

page_viewed is a page() and a <Page type> Page View track: the page type is <meta name="next-page-type">, else nextConfig.pageType, else product; the page name <meta name="next-page-name">, else the page's title. Every track carries page_type, page_name and the campaign_* fields. cart_id and checkout_id are the session id, the same across the cart, the checkout and the order. identify() comes when the shopper leaves their details (with an email) and before each Order Completed, from the order's billing address. Checkout Step Completed is sent once per checkout, for the first of its two tracking events. Order Completed prices are before tax, unless the campaign's prices include it, with total = subtotal + tax + shipping; each accepted upsell is an Order Completed of its own.

page

page(page type, page name, properties), then a <Page type> Page View track with page_name added. See the RudderStack reference.

From page_viewed.

The fields of RudderStackPageProperties.

CODE
rudderanalytics.page('product', 'Olympus Earbuds', {
  path: '/checkout/',
  url: 'https://shop.test/checkout/',
  title: 'Olympus Earbuds',
  referrer: '',
  campaign_name: 'Olympus',
  campaign_api_key: 'pk_test',
  campaign_currency: 'USD',
  campaign_language: 'en',
  campaign_id: '1310',
  campaign_session_id: '0b8f3c2d1e4a4f6b9c7d5e3f2a1b0c9d',
});
rudderanalytics.track('Product Page View', {
  page_name: 'Olympus Earbuds',
  path: '/checkout/',
  url: 'https://shop.test/checkout/',
  title: 'Olympus Earbuds',
  referrer: '',
  campaign_name: 'Olympus',
  campaign_api_key: 'pk_test',
  campaign_currency: 'USD',
  campaign_language: 'en',
  campaign_id: '1310',
  campaign_session_id: '0b8f3c2d1e4a4f6b9c7d5e3f2a1b0c9d',
});

identify

identify(email, traits) once the shopper left their details, and identify(email or order id, traits) before each Order Completed. See the RudderStack reference.

From checkout_contact_info_submitted, checkout_completed, upsell_completed.

The fields of RudderStackTraits.

CODE
rudderanalytics.identify('jane@example.com', {
  email: 'jane@example.com',
  firstName: 'Jane',
  lastName: 'Doe',
});

Product Viewed

A product the shopper sees. See the RudderStack reference.

From product_viewed.

The fields of RudderStackProduct and RudderStackContext, and:

FieldType
currencystringISO 4217, such as USD.
CODE
rudderanalytics.track('Product Viewed', {
  product_id: '400',
  sku: '11',
  name: 'Earbuds ×1',
  price: 49,
  quantity: 1,
  url: 'https://shop.test/checkout/',
  position: 0,
  category: 'Olympus',
  image_url: 'https://cdn.test/1.png',
  currency: 'USD',
  page_type: 'product',
  page_name: 'Olympus Earbuds',
  campaign_name: 'Olympus',
  campaign_api_key: 'pk_test',
  campaign_currency: 'USD',
  campaign_language: 'en',
  campaign_id: '1310',
  campaign_session_id: '0b8f3c2d1e4a4f6b9c7d5e3f2a1b0c9d',
});

Product List Viewed

The products a page shows. See the RudderStack reference.

From product_list_viewed.

The fields of RudderStackContext, and:

FieldType
productsRudderStackProduct[]
currencystringISO 4217, such as USD.
list_id"product_list"
category"Product List"
CODE
rudderanalytics.track('Product List Viewed', {
  products: [
    {
      product_id: '400',
      sku: '11',
      name: 'Earbuds ×1',
      price: 49,
      quantity: 1,
      url: 'https://shop.test/checkout/',
      position: 0,
      category: 'Olympus',
      image_url: 'https://cdn.test/1.png',
    },
    {
      product_id: '400',
      sku: '12',
      name: 'Earbuds ×2',
      price: 44.5,
      quantity: 2,
      url: 'https://shop.test/checkout/',
      position: 1,
      category: 'Olympus',
      image_url: 'https://cdn.test/2.png',
    },
  ],
  currency: 'USD',
  list_id: 'product_list',
  category: 'Product List',
  page_type: 'product',
  page_name: 'Olympus Earbuds',
  campaign_name: 'Olympus',
  campaign_api_key: 'pk_test',
  campaign_currency: 'USD',
  campaign_language: 'en',
  campaign_id: '1310',
  campaign_session_id: '0b8f3c2d1e4a4f6b9c7d5e3f2a1b0c9d',
});

Product Added

A product added to the cart. See the RudderStack reference.

From product_added_to_cart.

The fields of RudderStackProduct and RudderStackContext, and:

FieldType
cart_idstringThe session id: the same on the cart, the checkout and the order.
currencystringISO 4217, such as USD.
CODE
rudderanalytics.track('Product Added', {
  cart_id: '0b8f3c2d1e4a4f6b9c7d5e3f2a1b0c9d',
  product_id: '400',
  sku: '11',
  name: 'Earbuds ×1',
  price: 49,
  quantity: 1,
  url: 'https://shop.test/checkout/',
  position: 0,
  category: 'Olympus',
  image_url: 'https://cdn.test/1.png',
  currency: 'USD',
  page_type: 'product',
  page_name: 'Olympus Earbuds',
  campaign_name: 'Olympus',
  campaign_api_key: 'pk_test',
  campaign_currency: 'USD',
  campaign_language: 'en',
  campaign_id: '1310',
  campaign_session_id: '0b8f3c2d1e4a4f6b9c7d5e3f2a1b0c9d',
});

Product Removed

A product removed from the cart. See the RudderStack reference.

From product_removed_from_cart.

The fields of RudderStackProduct and RudderStackContext, and:

FieldType
cart_idstringThe session id: the same on the cart, the checkout and the order.
currencystringISO 4217, such as USD.
CODE
rudderanalytics.track('Product Removed', {
  cart_id: '0b8f3c2d1e4a4f6b9c7d5e3f2a1b0c9d',
  product_id: '400',
  sku: '11',
  name: 'Earbuds ×1',
  price: 49,
  quantity: 1,
  url: 'https://shop.test/checkout/',
  position: 0,
  category: 'Olympus',
  image_url: 'https://cdn.test/1.png',
  currency: 'USD',
  page_type: 'product',
  page_name: 'Olympus Earbuds',
  campaign_name: 'Olympus',
  campaign_api_key: 'pk_test',
  campaign_currency: 'USD',
  campaign_language: 'en',
  campaign_id: '1310',
  campaign_session_id: '0b8f3c2d1e4a4f6b9c7d5e3f2a1b0c9d',
});

Cart Viewed

The cart after a price update. See the RudderStack reference.

From cart_updated.

The fields of RudderStackContext, and:

FieldType
cart_idstringThe session id: the same on the cart, the checkout and the order.
productsRudderStackProduct[]
currencystringISO 4217, such as USD.
valuenumberΣ price × quantity of products.
CODE
rudderanalytics.track('Cart Viewed', {
  cart_id: '0b8f3c2d1e4a4f6b9c7d5e3f2a1b0c9d',
  products: [
    {
      product_id: '400',
      sku: '11',
      name: 'Earbuds ×1',
      price: 49,
      quantity: 1,
      url: 'https://shop.test/checkout/',
      position: 0,
      category: 'Olympus',
      image_url: 'https://cdn.test/1.png',
    },
  ],
  currency: 'USD',
  value: 49,
  page_type: 'product',
  page_name: 'Olympus Earbuds',
  campaign_name: 'Olympus',
  campaign_api_key: 'pk_test',
  campaign_currency: 'USD',
  campaign_language: 'en',
  campaign_id: '1310',
  campaign_session_id: '0b8f3c2d1e4a4f6b9c7d5e3f2a1b0c9d',
});

Checkout Started

The checkout started. See the RudderStack reference.

From checkout_started.

The fields of RudderStackContext, and:

FieldTypePresent
valuenumberalwaysΣ price × quantity of products.
revenuenumberalwaysThe same as value.
currencystringalwaysISO 4217, such as USD.
affiliationstringalwaysThe campaign's name.
productsRudderStackProduct[]always
shippingnumberoptional
couponstringoptionalThe first code the shopper applied.
CODE
rudderanalytics.track('Checkout Started', {
  value: 49,
  revenue: 49,
  currency: 'USD',
  affiliation: 'Olympus',
  products: [
    {
      product_id: '400',
      sku: '11',
      name: 'Earbuds ×1',
      price: 49,
      quantity: 1,
      url: 'https://shop.test/checkout/',
      position: 0,
      category: 'Olympus',
      image_url: 'https://cdn.test/1.png',
    },
  ],
  shipping: 0,
  page_type: 'product',
  page_name: 'Olympus Earbuds',
  campaign_name: 'Olympus',
  campaign_api_key: 'pk_test',
  campaign_currency: 'USD',
  campaign_language: 'en',
  campaign_id: '1310',
  campaign_session_id: '0b8f3c2d1e4a4f6b9c7d5e3f2a1b0c9d',
});

Checkout Step Completed

The shipping step: once per checkout, for the first of its address and method. See the RudderStack reference.

From checkout_shipping_address_submitted, checkout_shipping_method_submitted.

The fields of RudderStackContext, and:

FieldType
checkout_idstringThe session id: the same on the cart, the checkout and the order.
step2
shipping_methodstringThe method's name, else Standard.
CODE
rudderanalytics.track('Checkout Step Completed', {
  checkout_id: '0b8f3c2d1e4a4f6b9c7d5e3f2a1b0c9d',
  step: 2,
  shipping_method: 'Standard',
  page_type: 'product',
  page_name: 'Olympus Earbuds',
  campaign_name: 'Olympus',
  campaign_api_key: 'pk_test',
  campaign_currency: 'USD',
  campaign_language: 'en',
  campaign_id: '1310',
  campaign_session_id: '0b8f3c2d1e4a4f6b9c7d5e3f2a1b0c9d',
});

Payment Info Entered

The payment details were submitted. See the RudderStack reference.

From checkout_payment_info_submitted.

The fields of RudderStackContext, and:

FieldTypePresent
checkout_idstringalwaysThe session id: the same on the cart, the checkout and the order.
step3always
payment_methodstringoptionalCredit Card for a card, else the API's code, such as paypal.
CODE
rudderanalytics.track('Payment Info Entered', {
  checkout_id: '0b8f3c2d1e4a4f6b9c7d5e3f2a1b0c9d',
  step: 3,
  payment_method: 'Credit Card',
  page_type: 'product',
  page_name: 'Olympus Earbuds',
  campaign_name: 'Olympus',
  campaign_api_key: 'pk_test',
  campaign_currency: 'USD',
  campaign_language: 'en',
  campaign_id: '1310',
  campaign_session_id: '0b8f3c2d1e4a4f6b9c7d5e3f2a1b0c9d',
});

Order Completed

An order was paid: the order, or one accepted upsell with its own order_id. See the RudderStack reference.

From checkout_completed, upsell_completed.

The fields of RudderStackContext, and:

FieldTypePresent
checkout_idstringalwaysThe session id: the same on the cart, the checkout and the order.
currencystringalwaysISO 4217, such as USD.
order_idstringalwaysThe tracking event's event_id: the order number, or <ref_id>-US<n> for an upsell.
affiliationstringalwaysOnline Store, or Upsell.
subtotalnumberalwaysΣ price × quantity of products.
revenuenumberalwaysThe same as subtotal.
totalnumberalwayssubtotal + tax + shipping.
shippingnumberalways
taxnumberalways
productsRudderStackProduct[]always
discountnumberoptional
couponstringoptional
CODE
rudderanalytics.track('Order Completed', {
  checkout_id: '0b8f3c2d1e4a4f6b9c7d5e3f2a1b0c9d',
  order_id: '1001',
  affiliation: 'Online Store',
  subtotal: 89,
  revenue: 89,
  total: 106.11,
  shipping: 9.99,
  tax: 7.12,
  currency: 'USD',
  products: [
    {
      product_id: 'EB-2',
      sku: 'EB-2',
      name: 'Earbuds',
      price: 44.5,
      quantity: 2,
      url: 'https://shop.test/checkout/',
      position: 0,
      category: 'Olympus',
      brand: 'Olympus',
      image_url: 'https://img.test/eb.png',
    },
  ],
  page_type: 'product',
  page_name: 'Olympus Earbuds',
  campaign_name: 'Olympus',
  campaign_api_key: 'pk_test',
  campaign_currency: 'USD',
  campaign_language: 'en',
  campaign_id: '1310',
  campaign_session_id: '0b8f3c2d1e4a4f6b9c7d5e3f2a1b0c9d',
});

Upsell Viewed

An upsell offer was shown. See the RudderStack reference.

From upsell_viewed.

The fields of RudderStackUpsell and RudderStackContext.

CODE
rudderanalytics.track('Upsell Viewed', {
  order_id: 'R1',
  product_id: 'page_view',
  name: 'Upsell Page View',
  quantity: 1,
  currency: 'USD',
  page_type: 'product',
  page_name: 'Olympus Earbuds',
  campaign_name: 'Olympus',
  campaign_api_key: 'pk_test',
  campaign_currency: 'USD',
  campaign_language: 'en',
  campaign_id: '1310',
  campaign_session_id: '0b8f3c2d1e4a4f6b9c7d5e3f2a1b0c9d',
});

Upsell Skipped

An upsell offer was skipped. See the RudderStack reference.

From upsell_skipped.

The fields of RudderStackUpsell and RudderStackContext.

CODE
rudderanalytics.track('Upsell Skipped', {
  order_id: 'R1',
  product_id: '3',
  name: 'Earbuds case',
  quantity: 1,
  currency: 'USD',
  page_type: 'product',
  page_name: 'Olympus Earbuds',
  campaign_name: 'Olympus',
  campaign_api_key: 'pk_test',
  campaign_currency: 'USD',
  campaign_language: 'en',
  campaign_id: '1310',
  campaign_session_id: '0b8f3c2d1e4a4f6b9c7d5e3f2a1b0c9d',
});

Types

RudderStackPageProperties

The page of a page() call and its <Page type> Page View track.

FieldTypePresent
campaign_namestringoptional
campaign_api_keystringoptional
campaign_currencystringoptionalISO 4217, such as USD.
campaign_languagestringoptional
campaign_idstringoptionalThe campaign's id, as a string.
campaign_session_idstringoptionalThe tracking event's session_id.
pathstringalwaysThe page's path.
urlstringalwaysThe page, without its query string.
titlestringalways
referrerstringalwaysWithout the query string.

RudderStackTraits

The shopper, as identify() takes them.

FieldTypePresent
emailstringoptional
firstNamestringoptional
lastNamestringoptional
phonestringoptional
citystringoptional
statestringoptionalThe state or province code.
countrystringoptionalISO 3166-1 alpha-2.
postalCodestringoptional
acceptsMarketingtrueoptionalOnly when the shopper ticked the marketing checkbox.

RudderStackProduct

One product, as the RudderStack ecommerce spec names its fields.

FieldTypePresent
product_idstringalwaysThe product's id, else sku.
skustringalwaysThe product's SKU, else the package's external_id on a cart line and SKU-<product id> on an order line.
namestringalways
pricenumberalwaysWhat one unit costs; on an order, before tax unless the campaign's prices include it.
quantitynumberalways
urlstringalwaysThe page, without its query string.
categorystringoptionalThe campaign's name.
brandstringoptionalOn an order: the package's product name, else the campaign's name.
variantstringoptional
positionnumberalwaysPosition in products, from 0.
image_urlstringoptional

RudderStackContext

What every track call carries besides its own fields.

FieldTypePresent
campaign_namestringoptional
campaign_api_keystringoptional
campaign_currencystringoptionalISO 4217, such as USD.
campaign_languagestringoptional
campaign_idstringoptionalThe campaign's id, as a string.
campaign_session_idstringoptionalThe tracking event's session_id.
page_typestringalwaysmeta[name="next-page-type"], else nextConfig.pageType, else product.
page_namestringalwaysmeta[name="next-page-name"], else the page's title.

RudderStackUpsell

An upsell offer: the shown page, or the skipped package.

FieldType
order_idstringThe order the offer is for.
product_idstringpage_view for a shown offer, else the package's ref_id.
namestringUpsell Page View for a shown offer, else the package's name.
quantity1
currencystring