Analytics Bestellung tracken funtioniert nicht

Hallo,

bei mir wird das „purchase“ Event nicht in Google Analytics dargestellt.

Deshalb habe ich meinen eigenen Code auf der Checkout seite eingebaut.

Leider funktioniert dieser nicht immer… jemand Erfahrung? danke!!!

            setTimeout(function(){
                gtag("event", "purchase", {
                        transaction_id: '{{ page.order.id }}',
                        "value": {{page.order.price.totalPrice}},
                        "currency": "EUR",
                        "shipping": {{ page.order.shippingTotal }},
                        "tax": {{page.order.price.totalPrice - page.order.price.netPrice}},
                        items: [
                            {% for lineitem in page.order.lineItems.elements %}
                            {% if lineitem.type == 'product' %}
                            {
                                "id": "{{ lineitem.productId }}",
                                "name": "{{ lineitem.label }}",
                                "quantity": {{ lineitem.quantity }},
                                "list_position": {{ loop.index }},
                                "price": '{{ lineitem.unitPrice }}'
                                {% if loop.last %}
                            }
                        {% else %}
                    },
                    {% endif %}
                    {% endif %}
                    {% endfor %}
                ]
                });
            }, 1100);