Learn business growth with Google Analytics 4 › Forums › Google Analytics 4 › How can I exclude purchases with unassigned transaction IDs in GA4? › Reply To: How can I exclude purchases with unassigned transaction IDs in GA4?
-
From the code snippet you provided, it seems there could be instances where the orders do not have an associated order number, possibly leading to your ‘not set’ issue. To resolve this, you could add an additional if-statement to your script to check if the order number is defined before pushing the purchase event to the dataLayer. You can add the condition
if order.order_number
orif order.order_number != ""
before pushing the data to Google Analytics. This way, only transactions with a set transaction ID will be tracked. If your order_number is coming up as null in the first place, you might also need to review your order processing and data extraction to make sure all orders are properly assigned an order number.