A retry should preserve the identity of the purchase it is trying to deliver. Generating a new transaction_id for every HTTP attempt turns one order into several transaction identities. Reusing a constant for every order creates the opposite problem.

Google's transaction-ID guidance describes purchase deduplication for web streams and requires a unique transaction identifier for each order. That documented behavior should not be generalized to app streams.

The engineering task is to keep the order-to-event relationship stable before relying on any destination-side behavior.

Choose the identity at the order boundary

Use a durable identifier for the committed order that is suitable for analytics and contains no customer-identifying information. Both a browser confirmation flow and a server delivery worker should read the same intended order identity when they represent that purchase.

Do not create the transaction ID inside a transport retry callback. Likewise, do not tie it to a new page-view identifier when the customer refreshes an existing confirmation page.

Record delivery attempt metadata separately: attempt number, send time and response outcome. Those describe transmission. They should not silently redefine which order the purchase event represents.

If your application has several order identifier namespaces, define which one this adapter uses. A short counter that is unique only inside one tenant may need a stable non-sensitive namespace to avoid collisions in a shared analytics destination.

Test the same order and a different order

This complete Node.js program builds a synthetic purchase fragment. It does not send an event and is not a complete GA4 Measurement Protocol request:

import assert from 'node:assert/strict'; function purchase(order) { const id = order.analyticsId; if (typeof id !== 'string' || id.length === 0 || id !== id.trim()) { throw new TypeError('stable nonempty transaction identity required'); } if (!Number.isFinite(order.total)) throw new TypeError('numeric total required'); return { name: 'purchase', params: { transaction_id: id, value: order.total, currency: order.currency } }; } const order = { analyticsId: 'synthetic-order-7401', total: 29, currency: 'USD' }; const first = JSON.parse(JSON.stringify(purchase(order))); const retry = JSON.parse(JSON.stringify(purchase(order))); const nextOrder = purchase({ ...order, analyticsId: 'synthetic-order-7402' }); assert.equal(first.params.transaction_id, retry.params.transaction_id); assert.notEqual(nextOrder.params.transaction_id, first.params.transaction_id); assert.deepEqual(first, retry); assert.throws(() => purchase({ ...order, analyticsId: '' })); assert.throws(() => purchase({ ...order, analyticsId: ' ' })); assert.throws(() => purchase({ ...order, analyticsId: ' synthetic-order-7401' })); assert.throws(() => purchase({ ...order, analyticsId: 7401 })); 

The two positive identity assertions protect opposite failures: random IDs per attempt and one copied constant for all orders. You need both cases.

The adapter rejects leading or trailing whitespace instead of trimming the ID differently in different delivery paths. Choose a normalization policy upstream and persist the chosen value so every adapter receives the same identity.

Preserve a retry's event data deliberately

A stable ID is necessary for the intended relationship, but it does not make arbitrary payload changes harmless. If an order record changes between attempts, a worker that rebuilds the purchase from the latest record may send a different value with the same transaction ID.

Decide which committed purchase snapshot the event represents and retain enough immutable data to reproduce it. A durable outbox or equivalent application mechanism can tie event creation to the business operation. The exact transaction design depends on your storage system.

Do not treat another purchase event with the same ID and a changed amount as a general update operation. Follow the destination's documented correction and refund workflows for later business changes.

Keep delivery state and business state separate. A timeout after sending does not establish that the destination never saw the event. Preserve the ambiguous outcome and retry according to the documented integration contract.

Reject empty identities before sending

Google explicitly warns about empty transaction IDs. Treat an empty string as missing input rather than allowing many purchases to share it.

Add tests for missing, whitespace-only and wrong-type IDs at the adapter boundary. Do not let String(undefined) turn an absent ID into the literal text undefined, which can look nonempty while being shared by every malformed event.

Also inspect sample configuration copied into production. A hard-coded example order number can make local demos look consistent while collapsing distinct orders into one identity.

Avoid a fallback that silently invents a new ID whenever the durable one is unavailable. That hides an upstream order-state problem and makes later reconciliation harder.

Inspect browser and worker behavior together

Capture the serialized purchase fragment from the server path and the corresponding browser event in a controlled test. Compare the transaction ID, purchase value, currency and intended destination.

Refresh the confirmation flow and simulate a worker retry. Confirm that the same committed order retains its identity. Then create another synthetic order and confirm that it receives a different identity.

If a tag manager transforms the identifier, test its final output rather than only the application object supplied to it. Leading zeros, numeric coercion and template defaults can change the value after your adapter test passes.

Keep the test's stream type in the evidence. The documented transaction-ID deduplication scope matters when interpreting what you observe.

Verify destination behavior separately

Local assertions establish what your application generated. They do not prove delivery or destination-side deduplication.

Use controlled test traffic in the intended web stream and inspect the available event and reporting evidence under the documented behavior. Record the request metadata and observed outcome without assuming immediate updates in every reporting surface.

When counts differ, compare identities and destinations before changing the retry algorithm. A mismatch can originate in a second producer, a transformed ID or an event routed to another stream.

I maintain Pixellint. Its GA4 purchase checks help inspect the outgoing payload. Keep the order-identity regression beside your application code because the durable relationship between an order and its retries begins there.

Sources

Technical sources checked October 25, 2026. Drafted with AI; examples are synthetic unless explicitly stated otherwise.