Datalayer Tracking via DATA Reshape for WooCommerce

By Eduard Doloc

30+ active installationsVersion 1.1.0

Official WooCommerce integration for DATA Reshape: first-party ecommerce event tracking, delivered from your own subdomain.

Description

DATA Reshape for WooCommerce connects your store to the DATA Reshape platform. It pushes structured ecommerce events (product_viewed, product_added_to_cart, product_removed_from_cart, cart_viewed, checkout_started, checkout_completed, plus the billing, shipping and payment steps of checkout) into DATA Reshape’s reshape.push() queue. DATA Reshape’s loader, served from a tracking subdomain you control, delivers them to GA4, Meta, TikTok and every other destination you have connected.

Because the loader is served first-party, events are not blocked by ad blockers, ITP or the usual third-party-script defences that break conventional gtag/fbq/ttq setups. You do not need to fire those calls in parallel: DATA Reshape sends each event to every connected destination with that platform’s event name and field mapping.

This plugin does not replace analytics tools like Google Analytics or Meta Pixel. It replaces the fragile transport layer underneath them. Event processing and routing happen inside DATA Reshape.

An active DATA Reshape plan is required. Tracking logic, integrations and event delivery are managed in the DATA Reshape platform.

Server-side order webhook (API Events)

The API Events tab sends an order webhook from your server straight to DATA Reshape. It covers what the browser can’t: off-site payment gateways that confirm the order minutes or hours later (or where the shopper never returns to the thank-you page), and phone or admin orders that never had a browser session. The checkout_completed webhook uses the order number as its event ID, so DATA Reshape reconciles it with the browser purchase event. If one signal is missing, the other fills in, and the order is counted once. An order_canceled event covers cancellations and refunds, and Test mode checks real order payloads against DATA Reshape’s /test endpoint before you go live.

Features

Core Features

  • Global enable/disable for the integration
  • DATA Reshape library integration
  • Tracking subdomain support
  • Fully compatible with WooCommerce HPOS (High-Performance Order Storage)

Events

  • Product Viewed
  • Product Added to Cart: shop and archive grids, product pages, quick views and shortcode product forms, ?add-to-cart= links, the block shop grid and product form, the Mini-Cart and the block Cart
  • Product Removed from Cart: the classic cart and mini-cart widget, the Mini-Cart and the block Cart (where lowering a quantity counts as a removal)
  • Cart Viewed
  • Checkout Started
  • Checkout steps (Billing Address Added, Shipping Detail Added, Payment Method Selected) on both the block and the shortcode checkout
  • Checkout Completed

Consent

  • DATA Reshape detects most CMPs (Cookiebot, OneTrust, Termly and others) and Google Consent Mode v2 on its own, with nothing to set up in the plugin
  • A “Grant consent by default” toggle for stores that don’t run a CMP. It sends DATA Reshape’s native consent_updated push at session start, so events are processed straight away. Off by default; turning it on asks for an explicit GDPR confirmation
  • drswc_consent_payload filter to set the consent object from PHP

API Events (Server-side)

  • Server-to-server order webhook to DATA Reshape’s /webhooks/wordpress/event endpoint
  • Fires on the order status you choose (default Processing; any status your flow reaches, including custom statuses)
  • Covers off-site gateway returns (confirmed minutes or hours later, or the shopper never comes back) and phone or admin orders with no browser session
  • checkout_completed uses the order number as event ID, so DATA Reshape deduplicates it against the browser purchase event
  • order_canceled event on Cancelled and Refunded orders
  • Relays DATA Reshape’s first-party drespa cookie, captured on the order at checkout
  • Test mode sends payloads to the /test validation endpoint and shows the returned errors and warnings in the admin
  • Optional activity log (WooCommerce logs, source drswc-webhook) with a Logs tab in the settings for setup debugging
  • drswc_webhook_payload filter to customize the outgoing envelope

Advanced Tracking

  • Spec-shaped products with price_base and price; tax_included and tax_percent only when WooCommerce tax is enabled
  • Variations carry parent_id, parent_name, parent_sku and parent_url
  • Order-level and product-level coupons in dedicated coupons[] arrays
  • Shipping and payment methods as structured arrays on Checkout Completed
  • Categories as both category (primary) and categories[] with name and id
  • Stock status, product type, creation timestamp, image and gallery images
  • User data is sent unhashed; DATA Reshape hashes it server-side

Extensibility

  • drswc_event_payload: filter the full event envelope before it is pushed
  • drswc_product_payload: add GTIN/MPN/EAN, predicted values or custom properties per product
  • drswc_user_payload: extend the user identity (pre_purchase or purchase source)
  • drswc_consent_payload: replace or inject the consent object
  • drswc_webhook_payload: customize the server-side order webhook envelope

Reliability

  • Classic form submissions and ?add-to-cart= links are tracked even when the plugin’s JavaScript fails to load, including with WooCommerce’s redirect to the cart page
  • Simple products added on the product page are still tracked when a bundle or volume-discount plugin takes over the click
  • Product-page adds are still tracked when admin-ajax.php is blocked
  • Works with JavaScript optimizers that defer or delay scripts (Cloudflare Rocket Loader, WP Rocket, Perfmatters, LiteSpeed): events wait for the plugin’s script instead of failing
  • Cache-safe identity: personal data is never written into cacheable HTML
  • Sticky user identity (the loader keeps the first user it sees, and later events inherit it)
  • The plugin’s add-to-cart detection methods share one duplicate check, so an add that several of them see is sent once

Configuration

Integration Setup

  • Enable Integration (master switch)
  • Tracking Subdomain (the first-party host serving DATA Reshape’s loader)
  • Library ID
  • Built-in “Check tracking endpoint” health check
  • Access token (the credential for the API Events order webhook; the webhook reuses your Tracking subdomain and Library ID)

Events

  • Master switch for browser-delivered events (on by default)
  • Per-event toggles, all on by default, so you can turn off any event your store already sends with custom code
  • Consent section with the “Grant consent by default” toggle. Leave it off to let DATA Reshape detect your CMP or Google Consent Mode; turn it on only if you don’t run a CMP and have a lawful basis to track without one. Enabling it asks you to confirm the GDPR implications, and the section stays highlighted while it is active

API Events

  • Enable order webhook (server-to-server checkout_completed)
  • Send order when status becomes … (default Processing; choose the status your payment flow reaches)
  • Sends order_canceled automatically on Cancelled and Refunded orders
  • Test mode (checks real payloads against the /test endpoint without delivering to destinations)
  • Log webhook activity (adds a Logs tab showing WooCommerce’s drswc-webhook logs, scrolled to the latest entry)
  • Requires your Tracking subdomain, Library ID and Access token under Integration setup

Installation

  1. Upload the plugin to the /wp-content/plugins/ directory
  2. Activate the plugin through the ‘Plugins’ screen in WordPress
  3. Ensure WooCommerce is installed and active
  4. Open the settings from either WooCommerce → Settings → DATA Reshape or Marketing → DATA Reshape (the page lives under WooCommerce Settings; the Marketing entry is a shortcut)
  5. Fill in your tracking subdomain and library ID (provided by DATA Reshape), enable the integration, and turn on the events you want sent

FAQ

Does this plugin support GA4?

Indirectly. Events go to DATA Reshape’s window.reshape queue, and DATA Reshape sends them to GA4 and every other connected destination with that platform’s event name and field mapping. You do not need to fire gtag, fbq or ttq calls in parallel.

Does it work without AJAX add-to-cart?

Yes. Classic form submissions, ?add-to-cart= links and WooCommerce’s “Redirect to the cart page after successful addition” option are all tracked. When an add happens on the server without the plugin’s JavaScript, it is sent on the page that loads next.

Does it support block themes and the block Cart and Checkout?

Yes. Since 1.1.0 it tracks block themes (tested with Twenty Twenty-Five and Purple), the block shop grid and product form, the Mini-Cart, and the block Cart and Checkout, as well as classic themes and the shortcode cart and checkout. Block cart changes are sent once WooCommerce confirms them, inside WooCommerce’s own responses, so there are no extra requests.

Does it support server-side event tracking?

Yes. The API Events tab sends an order webhook from your server to DATA Reshape. It is not a copy of the browser events: because the tracking library is first-party, browser events already get through. The webhook covers what the browser can’t, namely off-site payment gateways that confirm the order later (or where the shopper never returns to the thank-you page) and phone or admin orders with no browser session. DATA Reshape matches the webhook with the browser purchase by order number, so each order is counted once.

Will this slow down my website?

No. It is lighter than traditional tracking plugins because it does very little work on your store: it builds each event once and hands it to DATA Reshape, which maps it and delivers it to every connected destination. There is no per-platform code running in the browser, and page loads add no database queries. Its own JavaScript is two small files (one more on the block checkout), and block cart changes are reported inside WooCommerce’s own responses, with no extra requests.

In our side-by-side test on the same store against GTM4WP, Pixel Manager and PixelYourSite, DATA Reshape added the least JavaScript and was the only one that added no database queries per page.

Is deduplication handled?

Yes. DATA Reshape deduplicates purchases and cancellations by order number, so the browser purchase and the order webhook count as one order. For add to cart, the plugin runs one duplicate check across its detection methods, so a click that several of them see is sent once.

Screenshots

Changelog

1.1.0

  • New: Block theme tracking: adds from the block shop grid and product form, plus adds, quantity changes and removals in the Mini-Cart and block Cart.
  • New: Billing, shipping and payment steps on the block checkout.
  • Fix: Purchases were not sent on block themes (e.g. Twenty Twenty-Five, Purple).
  • Fix: Block checkout purchases had no customer details.
  • Fix: The plugin forced block product pages into a full page reload on add to cart.
  • Fix: Grouped products are tracked per item, with no extra event for the group.
  • Fix: Adds rejected by WooCommerce (e.g. out of stock) are no longer sent from the server fallback.
  • Fix: Cart removals report the removed quantity.
  • Fix: Coupon ids match between cart and purchase events.
  • Fix: Add and remove events report the page they happened on.
  • Fix: The default payment method is now sent as a checkout step.
  • Fix: No JavaScript errors on add to cart when the plugin’s head script is blocked or fails to load.
  • Fix: The purchase identity cookie is removed after use on sites installed in a subfolder or with a custom cookie domain.
  • Fix: Settings tab labels are translatable.
  • Change: The tracking endpoint check and the order webhook refuse private and local network addresses.
  • Change: Only WooCommerce cart responses are read for block cart events; product listing responses are left alone.

1.0.8

  • Fix: Add-to-cart was not tracked for product forms outside the product page (quick view, shortcodes, landing pages, WPC AJAX Add to Cart).
  • Fix: Variable products added on classic product pages were tracked twice.
  • Fix: Adding a different product within a few seconds of another could be skipped.
  • Fix: External/affiliate product buttons no longer send an add-to-cart event.

1.0.7

  • Change: “Grant consent by default” moved to its own Consent section at the end of the Events tab, with a fuller explanation, a GDPR legal notice, a required confirmation before it can be enabled, and a highlighted “Active” state.
  • Change: On new installs, events tracking and every event toggle are on by default. Existing settings are unchanged.
  • Fix: The “Current order storage mode” and “Customer history sync” cards lost their styling on WooCommerce 11.

1.0.6

  • New: Romanian (ro_RO) translation. Translations now load from the bundled languages folder, or from a WordPress.org language pack when one is available for your locale.

1.0.5

  • New: The API Events webhook reports the order creation source to website for storefront checkout, and distinct values for admin (admin), Point of Sale (pos-rest-api), and other API orders/methods.
  • New: Logged-in customers now include their WordPress user role in user.properties.role. Guest and anonymous visitors are unaffected.

1.0.4

  • Fix: Product, shipping, and coupon amounts now use one consistent tax basis, so stores that enter prices inclusive of tax no longer show non-sale products as discounted or under-report prices.

1.0.3

  • Fix: Removed a PHP “Undefined array key” warning that could appear on the settings screen when rendering the API Events tab.

1.0.2

  • Fix: Events could fail with “window.drswcPush is not a function” on sites that defer or delay JavaScript (Cloudflare Rocket Loader, WP Rocket / Perfmatters “delay JS”, LiteSpeed, etc.). Events now queue until the script loads instead of erroring, so none are lost.

1.0.1

  • Change: Failed, Cancelled, and Refunded are no longer selectable as the webhook trigger status: they aren’t completion signals (Cancelled/Refunded already send the dedicated order_canceled event).

1.0.0

  • New: Server-side order webhook (API Events tab). Sends a checkout_completed event server-to-server to DATA Reshape when an order reaches a configurable status (default Processing). It covers what the browser can’t: off-site payment gateways that confirm minutes or hours later (or where the shopper never returns to the thank-you page) and phone/admin orders that never had a browser session. Uses the order number as the event ID so DATA Reshape deduplicates it against the browser purchase event; if one signal is missing the other fills in, with no double counting.
  • New: order_canceled event sent on Cancelled / Refunded orders.
  • New: The webhook reuses your existing Tracking subdomain and Library ID; the only new credential is an Access token (the former “API key” field, relabeled). An admin error notice appears if the webhook is enabled without an Access token.
  • New: Relays DATA Reshape’s first-party drespa cookie, captured on the order at checkout so it survives gateway callbacks and admin actions.
  • New: The webhook sends the customer’s IP (from the WooCommerce order, which resolves the real visitor IP behind proxies/CDNs such as Cloudflare) so events aren’t attributed to the store server.
  • New: Test mode routes webhooks to DATA Reshape’s /test validation endpoint (nothing delivered to destinations) and surfaces the returned errors and warnings as an admin notice.
  • New: Optional “Log webhook activity” toggle records each request and response in the WooCommerce logs (source drswc-webhook) and reveals a Logs tab in the settings for setup debugging.
  • New: drswc_webhook_payload filter to customize the outgoing webhook envelope.
  • New: Staging/local safety guard. If the site address no longer matches where DATA Reshape was set up (e.g. a database copied to a staging or local site), tracking is paused automatically and an admin bar offers to resume live tracking, keep it in test mode (events sent as “dev”, not delivered), or dismiss, so a copy can’t pollute your production data.
  • New: A one-time welcome notice after activation prompts you to review every settings tab and configure it as needed.
  • New: A “Realtime Analytics” tab that opens the DATA Reshape realtime dashboard in a new browser tab.
  • Change: stock_status is now emitted as a string (“in stock” / “out of stock”) instead of a boolean, matching DATA Reshape’s stored format and avoiding a coercion warning.
  • Internal: the admin CSS and the static frontend JS were moved out of PHP into real assets/css and assets/js files, enqueued with the plugin version for cache-busting. No functional change.
  • Internal: the plugin was reorganized from one large file into a thin bootstrap plus focused trait files under includes/. It remains a single class/singleton; no functional change.
  • Compatibility: tested up to WordPress 7.0 and WooCommerce 11.0.

0.9.1

  • Fix: Add-to-cart now tracks reliably on stores where another plugin or theme intercepts the product-page button click before the standard handlers can run (volume-discount widgets, bundle plugins, one-click upsells, and similar).
  • Fix: Add-to-cart no longer silently drops when /wp-admin/admin-ajax.php is unreachable (security-plugin allow-lists, expired nonces, ad-blocker rules, network drops). The product-page event payload now ships pre-built with the page, so the push happens synchronously.

0.9

  • Fix: Add-to-cart now tracks reliably on themes that hijack the single-product form with their own AJAX (Woodmart, custom builders, etc.). A new product-page click handler on the standard .single_add_to_cart_button fires the event before the theme’s submit logic runs, regardless of which AJAX library or endpoint the theme uses. Built-in 3-second JS dedup prevents double-fire when both this path and the legacy AJAX-listener path would trigger.
  • Fix: Listing add-to-cart with WooCommerce’s “Redirect to cart page after successful addition” option enabled: the ?add-to-cart= link redirected to the cart page before any client-side hook could fire, so the event was lost. A new server-side woocommerce_add_to_cart action hook now stashes the pending event in session so it emits on the cart page after the redirect.
  • Fix: Variable products on classic (non-AJAX) single-product pages now emit the chosen variation as products[0].id instead of the parent product id. The POST capture path was previously ignoring variation_id.
  • Internal: the new server-side hook is intentionally gated on non-AJAX, non-REST, non-admin contexts so AJAX flows (already covered client-side) don’t double-fire.

0.8

  • Consent integration overhauled. The legacy “Google Consent Mode granted by default” toggle (emitted a gtag('consent', 'update', ...) block) and the per-event envelope consent_default_grant toggle have both been removed. A single new “Grant consent by default” toggle now fires DATA Reshape’s native consent_updated push at session start. DATA Reshape detects most CMPs and Google Consent Mode v2 on its own, so this toggle defaults to OFF.
  • Tax fields (tax_included, tax_percent) are now omitted entirely from product, coupon, and shipping payloads when WooCommerce tax is disabled (previously emitted as tax_included: false).
  • Settings tabs renamed for clarity: “Browser events” → “Events”, “Server-side events” → “API Events”. The API Events tab is reserved for admin-recorded events (e.g. phone-call orders) and historical customer/order backfill, not a CAPI-style server-side mirror of browser events.
  • Settings also reachable under Marketing → DATA Reshape (shortcut to the canonical WooCommerce → Settings → DATA Reshape page).
  • Field labels simplified: “Server-side API endpoint” / “Server-side API key” → “API endpoint” / “API key”.
  • Internal: narrative inline comments moved to CLAUDE.md; no functional impact.

0.7

  • Hard cutover from window.dataLayer to DATA Reshape’s window.reshape API. Event names updated to the new spec (product_viewed, product_added_to_cart, cart_viewed, checkout_started, checkout_completed, etc.).
  • Mid-funnel checkout events on legacy checkout: billing_address_added, shipping_detail_added, payment_method_selected.
  • “Grant consent by default” and “Track checkout steps” toggles added.
  • Identity emission tightened: user object sent only when logged in or in checkout with confirmed contact data.
  • Variations carry parent_* fields; products emit categories[], stock status, type, created_at, image, gallery.
  • Pricing decoupled from coupons: price / price_base are the buyer-visible regular / sale prices; coupons land in dedicated coupons[] arrays.
  • New filters: drswc_event_payload, drswc_product_payload, drswc_user_payload, drswc_consent_payload.

0.6

  • PII cache leak fix extended to cart/checkout pages (in addition to thankyou).
  • HPOS and Cart/Checkout Blocks compatibility declared.

0.5

  • Fixed PII leak on page-cached thankyou pages (LiteSpeed et al.); identity now hydrated client-side from cookies.
  • Removed browser-side SHA256 hashing; DATA Reshape hashes server-side.
  • On-save tracking endpoint health check plus on-demand re-check button.
  • wp.org update-available pill in the settings header.
  • Loader URL tags the installed plugin version (&wp=).

0.4

  • Fresh-install checkbox defaults flipped to off.
  • Admin warning notice when the plugin is active but not configured.

0.3

  • AJAX add-to-cart detection works with third-party plugins (QuadLayers etc.) and themes whose buttons don’t expose data-product_id.
  • Removed the in-page dataLayer debug overlay.

0.1

  • Initial release.