Untitled

mail@pastecode.io avatar
unknown
plain_text
a month ago
1.2 kB
1
Indexable
Never
<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: '"' }}",
       currency: "{{ order.currency }}",
       price: {{ line_item.final_price | times: 0.01 }},
       quantity: {{ line_item.quantity }}
     },{% endfor %}
]
 }
});
{% endif %}
</script>
 <!-- Google Tag Manager -->
 <script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
 new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
 j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
 'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
 })(window,document,'script','dataLayer','GTM-MB3Q39C');</script>
 <!-- End Google Tag Manager -->

Leave a Comment