-
How can I exclude purchases with unassigned transaction IDs in GA4?
Hey there, I’ve been messing around with a GA4 account for a mate’s Shopify store lately. I’ve hit a bit of a roadblock where I’m trying to stop sending purchases without transaction IDs to analytics/revenue count (aka when the transaction ID is (not set)). Just wondering if there’s a chance the solution could be brewing in the liquid on the checkout page? Here’s what the current purchase event looks like:
window.dataLayer = window.dataLayer || []; dataLayer.push({ ecommerce: null }); {% if first_time_accessed %} dataLayer.push({ event: "purchase", ecommerce: { transaction_id: "{{ order.order_number }}", value: {{ total_price | times: 0.01 }}, tax: {{ tax_price | times: 0.01 }}, shipping: {{ shipping_price | times: 0.01 }}, currency: "{{ order.currency }}", items: [ {% for line_item in line_items %}{ item_id: "{{ line_item.product_id }}", item_name: "{{ line_item.title | remove: "'" | remove: '"' }}", currency: "{{ order.currency }}", price: {{ line_item.final_price | times: 0.01 }}, quantity: {{ line_item.quantity }} },{% endfor %} ] } }); {% endif %}
Gotta say, any pointers here would be super appreciated!
Log in to reply.