Why isn't my GA4 Event 'purchase' dataLayer.push code working in Shopify?

Hello everyone,

I have found a GA4 Event ‘purchase’ dataLayer.push code model for shopify that I have modified a little, but It’s not firing.

Can a liquid developer please tell me where I messed up ?

I have put this code in Settings → Checkout → Order status page → Additional scripts

Thanks a lot !!

<script>
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: '"' }}",
        item_variant: '{% if product.selected_variant.title=="Default Title" %}undefined{% else %}{{ product.selected_variant.title }}{% endif %}',
        currency: "{{ order.currency }}",
        price: {{ line_item.final_price | times: 0.01 }},
        quantity: {{ line_item.quantity }}
      },{% endfor %}
 ]
  }
});
{% endif %}
</script>