Meta pixel

Sends six tracking events to the page's fbq as Meta Pixel standard events, fbq('track', name, params, { eventID }). The pixel's base code sends PageView itself. Vendor docs: Meta Pixel standard events.

Config

Off by default. On, with the store's name:

CODE
<script>
  window.nextConfig = {
    analytics: {
      destinations: { meta: { enabled: true, storeName: 'shop' } },
    },
  };
</script>

The 0.4.x analytics.providers.facebook.enabled: true turns it on too, and nextConfig.storeName is read when storeName is not set.

What loads

meta-*.js (about 2 KB), only when it is on. The SDK never loads the pixel: the page has its base code. Without fbq the SDK logs one warning and sends nothing.

Events

eventID is the tracking event's event_id, so a Conversions API event with the same id is counted once. With storeName, an order's Purchase has eventID: '<storeName>-<order number>', the id the store's server-side events use.

ViewContent

A product the shopper sees. See the Meta reference.

From product_viewed.

The fields of MetaContents.

CODE
fbq('track', 'ViewContent', {
  content_ids: ['1'],
  contents: [
    {
      id: '1',
      quantity: 1,
      item_price: 49,
    },
  ],
  content_type: 'product',
  content_name: 'Earbuds ×1',
  value: 49,
  currency: 'USD',
}, { eventID: '3f2b8c1d9e7a4b6c8d5e2f1a0b9c8d7e' });

AddToCart

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

From product_added_to_cart.

The fields of MetaContents.

CODE
fbq('track', 'AddToCart', {
  content_ids: ['1'],
  contents: [
    {
      id: '1',
      quantity: 1,
      item_price: 49,
    },
  ],
  content_type: 'product',
  content_name: 'Earbuds ×1',
  value: 49,
  currency: 'USD',
}, { eventID: '3f2b8c1d9e7a4b6c8d5e2f1a0b9c8d7e' });

InitiateCheckout

The checkout started. See the Meta reference.

From checkout_started.

The fields of MetaContents, and:

FieldType
num_itemsnumberHow many units the cart holds.
CODE
fbq('track', 'InitiateCheckout', {
  content_ids: ['1'],
  contents: [
    {
      id: '1',
      quantity: 1,
      item_price: 49,
    },
  ],
  content_type: 'product',
  content_name: 'Earbuds ×1',
  value: 49,
  currency: 'USD',
  num_items: 1,
}, { eventID: '3f2b8c1d9e7a4b6c8d5e2f1a0b9c8d7e' });

Lead

The shopper left their contact details. See the Meta reference.

From checkout_contact_info_submitted.

FieldTypePresent
valuenumberoptional
currencystringoptional
CODE
fbq('track', 'Lead', {
  value: 49,
  currency: 'USD',
}, { eventID: '3f2b8c1d9e7a4b6c8d5e2f1a0b9c8d7e' });

AddPaymentInfo

The payment details were submitted. See the Meta reference.

From checkout_payment_info_submitted.

The fields of MetaContents.

CODE
fbq('track', 'AddPaymentInfo', {
  content_ids: ['1'],
  contents: [
    {
      id: '1',
      quantity: 1,
      item_price: 49,
    },
  ],
  content_type: 'product',
  content_name: 'Earbuds ×1',
  value: 49,
  currency: 'USD',
}, { eventID: '3f2b8c1d9e7a4b6c8d5e2f1a0b9c8d7e' });

Purchase

An order was paid: the order, or one accepted upsell. See the Meta reference.

From checkout_completed, upsell_completed.

The fields of MetaContents, and:

FieldType
valuenumber
CODE
fbq('track', 'Purchase', {
  content_ids: ['EB-2'],
  contents: [
    {
      id: 'EB-2',
      quantity: 2,
      item_price: 44.5,
    },
  ],
  content_type: 'product',
  content_name: 'Earbuds',
  value: 89,
  currency: 'USD',
}, { eventID: '1001' });

With storeName: 'shop': { eventID: 'shop-1001' }.

Types

MetaContents

The parameters Meta's ecommerce standard events share.

FieldTypePresent
content_idsstring[]alwaysThe lines' SKUs, else their package ids.
contentsMetaContent[]always
content_type"product"always
content_namestringoptionalThe product name, when the event is about one product.
valuenumberoptionalWhat the lines cost.
currencystringoptionalISO 4217, such as USD.

MetaContent

One product of a Meta event's contents.

FieldTypePresent
idstringalwaysThe line's SKU, else its package id.
quantitynumberalways
item_pricenumberoptionalWhat one unit costs, when the line is priced.