Why WooCommerce fires purchase tags for failed orders
When WooCommerce order confirmation pages fire tags blindly, failed card payments inflate your revenue. We explain how to gate the dataLayer output correctly.
Your WooCommerce store is inflating your analytics revenue because the tracking script fires a purchase event simply because the 'Order Received' page loaded. The website does not check whether the credit card actually cleared before sending the data. If a customer's payment fails and WooCommerce redirects them to an 'Order Failed' view, or if a bank transfer sits in an 'On Hold' status, your marketing tags blindly record it as successful cash in the bank.
When a brand instals a generic tracking plugin or pastes a snippet from a tutorial, they assume the code is intelligent enough to know what a sale is. They check GA4 on Monday morning and celebrate a £15,000 weekend.
We check the actual WooCommerce ledger. The store only processed £11,000 in cleared funds. The missing £4,000 consists of declined cards, pending invoices, and abandoned PayPal redirects. The business is treating bad debt as marketing success.
The mechanics of the order received page
In the WooCommerce architecture, the checkout process culminates in the is_order_received_page() endpoint. This is the standard 'Thank You' URL structure (/checkout/order-received/12345/).
Basic tracking setups bind the Google Tag Manager (GTM) dataLayer.push() directly to this endpoint. If the URL contains order-received, the script executes and sends the purchase event to Google Ads, Meta, and GA4.
The flaw is that WooCommerce uses this exact same endpoint to display order failures. If a Stripe payment declines, WooCommerce still generates an order number, assigns it a 'Failed' status in the database, and loads the order-received page with a red error message asking the user to try another card.
| Order Scenario | WooCommerce Database Status | Page Loaded | Analytics Output |
|---|---|---|---|
| Card clears successfully | processing | Order Received | Purchase Counted (£500) |
| Card declined by bank | failed | Order Received (Error state) | Purchase Counted (£500) |
| Bank transfer requested | on-hold | Order Received (Instructions) | Purchase Counted (£500) |
Because the basic tracking script cannot read the red error message on the screen, it assumes the presence of an order number in the URL means a victory. It tells your ad platforms that the £500 transaction is complete.
The financial cost of tracking failures
When you feed failed transactions into an algorithmic bidding platform like Google Ads, you actively damage your campaign efficiency.
Consider a B2B supplier selling £2,000 wholesale pallets. They rely heavily on 'BACS / Bank Transfer' for their trade accounts, which immediately places the order into 'On Hold' status pending manual reconciliation.
| Checkout Event | Actual Bank Deposit | Google Ads Tracked Revenue | The Advertising Consequence |
|---|---|---|---|
| 5x Card Payments | £10,000 | £10,000 | Normal optimisation. |
| 2x Card Declines | £0 | £4,000 | Algorithm hunts for more bad cards. |
| 3x BACS (Never paid) | £0 | £6,000 | Algorithm optimises for unpaid invoices. |
| Weekly Total | £10,000 | £20,000 | 100% Artificial ROAS Inflation. |
If your Google Ads dashboard claims £20,000 in revenue, the Smart Bidding algorithm believes it is doing an exceptional job. It will increase the bids on the keywords that drove the declined cards and the unpaid invoices, because those conversions look identical to the legitimate sales. You are spending your ad budget to acquire customers who cannot or will not pay you.
Gating the data layer in the backend
If you are auditing your eCommerce tracking setup, the fix requires moving the intelligence out of the browser and into the server.
We check the PHP logic generating the dataLayer. You cannot rely on GTM to figure out if an order is valid just by looking at the URL. GTM is a passive recipient. The website must act as the gatekeeper.
We rewrite the WooCommerce tracking snippet so it interrogates the order status before it writes the JavaScript to the page. In WooCommerce, every order object has a get_status() method. We wrap the dataLayer.push() in a strict conditional rule: it is only allowed to output the purchase event if the order status strictly equals processing (paid) or completed (dispatched).
If the status is failed, cancelled, or on-hold, the PHP simply outputs nothing. GTM loads, finds an empty data layer, and keeps quiet. The analytics platforms record exactly zero revenue.
The aim is straightforward. The marketing reports must match the reality of your merchant account, not the optimism of an error page.
Frequently asked questions
Can we just use a GTM trigger to block failed pages?
Sometimes, but it is fragile. You could configure GTM to look for the words "Payment Failed" on the screen and block the tag. However, if you change your theme, translate the site, or install a new payment gateway that uses a different error message, the text-based block will fail and the false revenue will return. Server-side PHP gating is bulletproof.
What if we want to track 'On Hold' bank transfers?
If you consider an 'On Hold' BACS order a legitimate conversion, you can add on-hold to the list of approved statuses in the PHP conditional logic. However, if half of those buyers never actually transfer the money, your analytics will over-report your revenue. It is a commercial decision about your acceptable variance.
Do WooCommerce tracking plugins fix this automatically?
Premium, well-maintained plugins usually include logic to gate the purchase event based on order status. Free snippets copied from outdated blogs or basic integration tools rarely do. If your revenue figures are drifting from your bank deposits, the plugin is the first thing to check.
Does this apply to Shopify as well?
Shopify handles this differently. Shopify's core checkout generates distinct states, and its native integrations generally prevent failed cards from triggering the final purchase webhook. However, if you use custom pixels or third-party upsell apps on Shopify, similar race conditions can occur.
Will fixing this drop my Google Ads performance?
In the short term, your Google Ads reported Return on Ad Spend (ROAS) will drop because you are stripping out the fake revenue. The platform might temporarily reduce traffic as it adjusts to the true, lower conversion volume. In the long term, the algorithm will stop wasting your budget on failed transactions, improving your actual cash profitability.