Library·SOP·Analytics

Track WooCommerce purchases in GA4 with Google Tag Manager

Send Google Analytics 4 (GA4) WooCommerce order items, value, currency, and a unique order number when the buyer’s browser reaches the order confirmation page while the order has a status the store counts as a purchase. GTM4WP adds the order data to the data layer, and one Google Tag Manager event tag sends it. A later order-status change in WordPress does not send this browser event by itself.

Last reviewed: · Editorial review

Clarity, structure and references reviewed in this version. This is not a test in a live account.

SOP 026 · 45 min
SOPFree

Track WooCommerce purchases in GA4 with Google Tag Manager

SOP 026 · 45 min

Send Google Analytics 4 (GA4) WooCommerce order items, value, currency, and a unique order number when the buyer’s browser reaches the order confirmation page while the order has a status the store counts as a purchase. GTM4WP adds the order data to the data layer, and one Google Tag Manager event tag sends it. A later order-status change in WordPress does not send this browser event by itself.

Scope

This SOP covers:

This does not cover:

Requirements

01. Choose what the store counts as a purchase

GTM4WP checks the order status, but this setup sends the event from the buyer’s browser. The buyer must reach the order confirmation page while the order has a selected status. A later WordPress status change by itself does not send the event.

  1. Create a note called WooCommerce GA4 purchase note. Use the headings Website, GA4 property, Stream Measurement ID, Container ID and loader, Purchase rule and statuses, Test checkout, Preview, and Live.

    1. Add the website address and GA4 property name at the top of the note. Keep customer names, email addresses, addresses, and payment details out. It is fine to record the non-personal test order ID and totals needed for the test.

    2. In Google Analytics, open Admin > Data collection and modification > Data streams. Choose Web, then open the stream for this store. Copy its Measurement ID (starts with G-) into Stream Measurement ID in the note.

  2. Ask the store owner which orders GA4 should count, and when the buyer returns to the order confirmation page. Use the store’s payment methods to choose the statuses.

    • Warning: The status alone does not send this event. The buyer’s browser must load the order confirmation page while the order qualifies.
    • Resource: WooCommerce order statuses (Explain what WooCommerce statuses say about payment and fulfillment.)
    • Resource: WooCommerce Cash on Delivery (Confirm that COD orders can remain Processing before payment is collected.)
    1. For a typical card order, Processing usually means payment has been received and the order is waiting for fulfillment, so it can be the purchase status at checkout. Completed usually means fulfillment has finished. If WordPress changes an order from Processing to Completed days later, that later change will not send this browser event unless the buyer returns to the confirmation page while Completed is selected.

    2. For cash on delivery, Processing can happen before the driver collects payment. Ask the owner whether the business counts the order at checkout or only after collection. If payment happens later and buyers do not return to the site, ask the maintainer for server-side purchase tracking; this browser-based method cannot send the event from a later WordPress status change.

    3. Write the owner’s rule, the selected WooCommerce status or statuses, and whether the buyer returns to the confirmation page under Purchase rule and statuses. Keep Pending payment, Failed, and On hold out of this recipe because payment is missing or not confirmed.

  3. Ask the website maintainer for the approved no-charge test checkout. Record where to start, how to place two Preview orders with different items or totals and one fresh Live order, and how the buyer reaches the order confirmation page under a selected status in Test checkout.

    • Warning: Do not place a paid order for this test. If there is no no-charge route that returns to the confirmation page, ask the maintainer for another test method.

02. Connect WooCommerce order data to the existing container

A data layer is a page’s shared list of events and values that Google Tag Manager can read. GTM4WP adds WooCommerce purchase data to that list; its separate container-code setting controls whether GTM4WP also loads the GTM container.

  1. Find the existing GTM container ID and confirm which one component loads it on the store.

    1. Open the existing container in Google Tag Manager and copy the GTM- ID shown near the top into Container ID and loader in your note. Ask the site maintainer whether Site Kit, GTM4WP, or another snippet loads this container if you are not sure.

    2. Open Google Tag Assistant and connect to the store. Confirm that the same container ID appears once. If it is missing or appears more than once, ask the maintainer to fix the loader before changing plugin settings.

  2. Open GTM4WP and turn on its WooCommerce data layer while keeping the container loader that you confirmed in the previous step.

    • Warning: If you cannot tell which component loads the container, stop and ask the maintainer before changing Container code placement.
    • Resource: GTM4WP WooCommerce settings reference (Confirm the current ecommerce and data layer settings.)
    • Resource: GTM4WP container settings reference (Confirm that container placement Off leaves the data layer available when another loader owns GTM.)
    1. In WordPress, open Plugins > Installed Plugins. If Google Tag Manager for WordPress (GTM4WP) is inactive, select Activate. Then open Settings > Google Tag Manager > WooCommerce. The settings page is available only while the plugin is active.

    2. Under General, turn Track e-commerce On. This is the switch that lets GTM4WP put WooCommerce events into the data layer.

    3. Under Data layer content, leave Customer data in data layer and Order data in data layer Off. The purchase event uses the ecommerce item data and does not need customer details or the full order record.

    4. Under Google Tag Manager > Container code placement, keep the component confirmed in step 2.1 as the only loader. If Site Kit or another snippet loads this container, choose Off – container code turned off, data layer only in GTM4WP. If GTM4WP is the confirmed sole loader, keep its placement active and make sure the saved container ID matches the ID in your note. Leave the data layer name as dataLayer unless the maintainer confirms that the container uses a different name.

  3. Set GTM4WP to send only eligible order data and to keep its repeat-order protection on.

    1. In WooCommerce > Purchase tracking, select only the status or statuses recorded in your note. Leave Pending payment, Failed, and On hold unchecked.

    2. Turn Exclude tax from revenue and Exclude shipping from revenue On. Leave Do not flag orders as being tracked unchecked; this keeps GTM4WP from sending the same order again when its confirmation page is reloaded. Leave Transaction ID prefix empty unless the store already uses a prefix convention.

    3. Select Save changes and record the selected statuses, value options, and repeat-protection state under Purchase rule and statuses in your note.

03. Create one GA4 purchase event tag

Use the exact purchase event so product views, cart actions, and checkout starts do not count as orders.

  1. Confirm the existing Google tag sends to the intended GA4 web stream, then check that no other tag or plugin is already sending purchases to that stream.

    1. In Google Tag Manager, open the identified container and open its existing Google tag. Confirm its destination is the web stream whose Measurement ID is in your note. Keep this Google tag in place. If it is missing or points to another stream, follow the related installation guide before continuing.

    2. In the GTM Tags list, open existing Google Analytics: GA4 Event tags and inspect each tag’s Event Name and Measurement ID fields for purchase sent to the stream ID in your note. Also check Plugins > Installed Plugins for another WooCommerce-to-GA4 tracking plugin. If another source may send purchase to the same Measurement ID, ask the maintainer which single sender to keep before proceeding.

  2. Create a GA4 Event tag named GA4 - WooCommerce purchase for the intended web stream.

    1. In the same GTM container, create a new tag and choose Google Analytics: GA4 Event as its type. Enter purchase in Event Name.

    2. Enter the stream Measurement ID from your note in the tag’s Measurement ID field. Keep the existing Google tag in place as the base tag.

    3. Under More Settings > Ecommerce, turn on Send Ecommerce data and choose Data Layer as the source. GTM4WP provides each order’s current items, prices, quantities, currency, value, and transaction ID; do not enter fixed order values.

  3. Create a trigger named WooCommerce purchase event. Choose Custom Event, enter the exact event name purchase, and leave it set to all custom events with that name. Attach it to GA4 - WooCommerce purchase, then save the trigger and save the tag.

  4. In the matching GA4 property, open Admin > Data display > Events and check that the existing purchase event is marked as a key event. If it is already marked, leave it as it is. If it is listed but not marked, mark that existing event; do not create another event. Record the visible state in Live in your note.

04. Test the order data and check the live GA4 event

Repeat the relevant success check with consent accepted and refused, and compare tag/request behavior with the approved consent implementation. Record both results. Do not force consent to Granted or bypass the banner to obtain a passing test.

Use a fresh order for each distinct Preview or Live success check. Keep a test-order register with order IDs, expected values, environment and test time. Coordinate test orders with the store owner so they do not trigger real fulfillment; record their treatment in business reports. Do not disable repeat-order protection to reuse an already tracked order.

Preview with two safe no-charge orders first. Then publish the tag and check that GA4 receives the event details and items.

  1. Use GTM Preview to connect Tag Assistant to the store, then confirm that no purchase tag fires before an eligible order.

    1. In the GTM container workspace, select Preview. Enter the test checkout address from your note and connect Tag Assistant.

    2. Visit the product, cart, and checkout pages without placing an order. In Tag Assistant, check each page’s event list and confirm GA4 - WooCommerce purchase has not fired.

  2. Place the first approved no-charge order and inspect its purchase event in Tag Assistant.

    1. Use the checkout in your note to place one no-charge test order. Make sure the buyer’s browser returns to the order confirmation page while the order has a selected status.

    2. In Tag Assistant, select the purchase event. Confirm GA4 - WooCommerce purchase fired once. Open the event’s data and check that transaction_id is the WooCommerce order number, currency matches the store, value matches the item total without tax or shipping, and items lists the test product with its item ID or name, price, and quantity.

  3. Place a second approved no-charge order with a different item or total. In Tag Assistant, check that it has a different transaction ID and that its value and items match the second order.

  4. Check that unconfirmed orders stay out and a repeat page view does not send the same order twice.

    • Warning: If an excluded status sends a purchase or a reload sends the same order again, return to the status list and repeat-order setting before publishing.
    1. If the no-charge route can create a Pending payment, Failed, or On hold order, open its confirmation page and check that the purchase tag does not fire. If the route cannot create one of these statuses safely, record that it was not tested.

    2. Reload the confirmation page for an eligible test order. Check that the purchase tag does not fire a second time for that order.

  5. Review the GTM workspace changes and publish the new purchase tag and trigger to the existing container. Name the version WooCommerce GA4 purchase and record its version number under Live in your note.

  6. Start a fresh Live Tag Assistant check, place a new eligible order, and confirm that GA4 received its purchase event and item details.

    1. In Tag Assistant, open the connected container details. Select Change container environment or version. Choose Environment ID 1 / Live, then select its Debug link. When Tag Assistant says the container is updated for debugging, select Reload page. Before testing, confirm the container details show Container Version Live.

    2. Use the approved no-charge checkout for one new eligible order and let the buyer’s browser reach the confirmation page. Confirm the purchase tag succeeds once in the Live Tag Assistant session.

    3. In Google Analytics, open Admin > Data display > DebugView. In the Debug Device dropdown, select the browser used for the live test. Find and select the fresh purchase marker for your test order.

    4. With the purchase event selected, open Parameters. Confirm transaction_id matches the test order number, value matches its total under your selected tax/shipping rule, and currency matches the store.

    5. Open Items and expand the product row. Confirm its item ID or name and quantity match the test order.

    6. Compare the item price with the normal price shown in the successful Tag Assistant purchase event. DebugView may display an item price multiplied by 1,000,000 (for example, 12.34 as 12340000); do not change the store price to match that display. Record the event time, order ID, value, currency, item ID or name, quantity, and price comparison under Live in your note.