RUM community plugins

A personal community project under @kyletaylored, MIT licensed.Not provided or supported by Datadog.

← All plugins

WooCommerce

Cart, checkout and order events from WooCommerce's own storefront DOM events, plus order data printed on the order-received page.

Maintainercommercev0.1.0schema 1.0.0

Install

import { datadogRum } from '@datadog/browser-rum'
import { wooCommercePlugin } from '@kyletaylored/datadog-rum-plugin-woocommerce'

datadogRum.init({
  applicationId, clientToken, site, service, env, version,
  plugins: [wooCommercePlugin()],
})

The CDN URL is pinned to an exact version and needs the integrity hash from that release; there is no auto-updating latest URL. Platform path: WordPress plugin.

Events this plugin sends

Generated from this adapter's fixture run, not written by hand, so it describes what the code actually does. Attribute types are the schema's.

commerce.add_to_cart

AttributeType
cart_idstring
currencystring
item_countinteger
itemsarray
unique_itemsinteger
valuenumber
Example from the fixtures
{
  "value": 56,
  "currency": "USD",
  "cart_id": "c1-8f2a",
  "items": [
    {
      "item_id": "TEE-RED-M",
      "item_name": "Classic Tee",
      "price": 28,
      "quantity": 2,
      "item_variant": "Red / M",
      "item_category": "Shirts"
    }
  ],
  "item_count": 2,
  "unique_items": 1
}

commerce.purchase

AttributeType
couponstring
currencystring
item_countinteger
itemsarray
payment_typestring
shippingnumber
shipping_tierstring
taxnumber
transaction_idstring
unique_itemsinteger
valuenumber
Example from the fixtures
{
  "transaction_id": "wc_1042",
  "value": 100.6,
  "currency": "USD",
  "tax": 6.2,
  "shipping": 4.95,
  "coupon": "WELCOME10",
  "payment_type": "paypal",
  "shipping_tier": "Ground",
  "item_count": 3,
  "unique_items": 2,
  "items": [
    {
      "item_id": "TEE-RED-M",
      "item_name": "Classic Tee",
      "price": 28,
      "quantity": 2,
      "item_variant": "Red / M",
      "item_category": "Shirts"
    },
    {
      "item_id": "CAP-BLK",
      "item_name": "Logo Cap",
      "price": 28.5,
      "quantity": 1,
      "item_category": "Hats"
    }
  ]
}

commerce.remove_from_cart

AttributeType
cart_idstring
currencystring
item_countinteger
itemsarray
unique_itemsinteger
valuenumber
Example from the fixtures
{
  "value": 28.5,
  "currency": "USD",
  "cart_id": "c1-8f2a",
  "items": [
    {
      "item_id": "CAP-BLK",
      "item_name": "Logo Cap",
      "price": 28.5,
      "quantity": 1,
      "item_category": "Hats"
    }
  ],
  "item_count": 1,
  "unique_items": 1
}

Session context it sets

PropertyExample value
commerce.platform"woocommerce"
commerce.plugin_version"0.1.0"
commerce.schema_version"1.0.0"
store.id"shop.example.com"
store.currency"USD"
store.locale"en-US"
customer.type"returning"

What it touches

Platform globals readwindow.ddRumWooCommerce, window.jQuery, document.body
Platform events subscribedwc-blocks_added_to_cart, wc-blocks_removed_from_cart, wc-blocks_product_list_rendered, added_to_cart, removed_from_cart
Storage keys writtendd_rum_commerce_seen
RUM APIs calledaddAction, setGlobalContextProperty, setUser, clearUser
Consent sourceWP Consent API (via the consent option or a consent plugin)

Declared by the plugin and checked against its fixture run: the conformance suite fails if the adapter calls a RUM API this list does not mention. Also printed to the console in debug mode.

Options

OptionDefaultEffect
eventsnoneAllow-list of commerce actions. Every action in the schema by default.
identifyUserstrueCall setUser with the WordPress user ID.
includeEmailfalseAdd the customer email to setUser.
includeNamefalseAdd the customer name to setUser.
includeItemsfalseAttach items[], capped at 20 entries.
actionPrefix"commerce."Rename the action prefix if the site has its own convention.
consent"auto"auto reads the consent signal, ignore skips the gate, or supply a resolver callback.
beforeTracknoneEdit or drop an event before it is sent.
dataGlobal"ddRumWooCommerce"Global holding the server-rendered store, customer and order payload.
debugfalseLog every mapped event to the console.

Compatibility and maintainer

RUM SDK@datadog/browser-rum@>=7.0.0 <8.0.0
Schema1.0.0 · reference
Platforms
WooCommerce >=8.0
Cart and Checkout blocks. Classic themes are covered through the jQuery added_to_cart event.
WordPress >=6.4
MaintainerKyle Taylor (@kyletaylored)
Sourcepackages/plugin-woocommerce

Verify the install

  1. Pass debug: true and reload. Every mapped event prints to the console, along with the plugin's declared footprint.
    plugins: [wooCommercePlugin({ debug: true })]
  2. Query the RUM Explorer for the first action. It should appear within a minute of the first matching interaction on the site.
    @type:action @action.name:commerce.add_to_cart
  3. Reconcile against the platform's own report before trusting the numbers. These are browser-measured and will undercount; the accuracy bar is within 5% of the platform admin over 7 days.