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?
-
It looks like you may need to add a conditional check to ensure that the
transaction_id
has a value before pushing the purchase event into thedataLayer
. Using Shopify’s Liquid language, you can implement a simple check around thedataLayer.push()
function that checks whether thetransaction_id
(ororder.order_number
in your code) has been set. You’d do this by wrapping the purchase event inside anif
statement that checks iforder.order_number
is not empty. If theorder.order_number
is not available, the purchase event won’t be pushed to the data layer. If there are other places in the code where you’re pushing data todataLayer
, you’d also need to implement similar conditional checks. As always, after making these changes, remember to test thoroughly to make sure it works as expected and does not interfere with other functions or tracking features.