-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhead.liquid
55 lines (51 loc) · 1.66 KB
/
head.liquid
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<!-- Global Site Tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id={{ integration['Property_ID'] }}"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', '{{ integration['Property_ID'] }}', { 'anonymize_ip': '{{ integration['anonymizeIp'] }}' });
gtag('event', 'add_to_cart', {
"items": [
{% for item in cart.items %}
{
"id": '{{ item.id }}',
"name": '{{ item.title }}',
"brand": '{{ item.vendor }}',
"category": '{{ item.category }}',
"quantity": '{{ item.quantity }}',
"price": '{{ item.price }}'
},
{% endfor %}
]
});
{% if template == 'thankyou' %}
gtag('event', 'purchase', {
'transaction_id': '{{ cart.order_code }}',
'affiliation': '',
{% if shop.shopify_compatibility? == true %}
'value': '{{ cart.total_price | divided_by: 100.0 }}',
{% else %}
'value': '{{ cart.total_price }}',
{% endif %}
'shipping': '',
'tax': '{{ cart.tax_amount }}',
"items": [
{% for item in cart.items %}
{
'id': '{{ cart.order_code }}',
'name': '{{ item.product.title }}',
'sku': '{{ item.code }}',
'category': '{{ item.category }}',
{% if shop.shopify_compatibility? == true %}
'price': '{{ item.line_price | divided_by: 100.0 }}',
{% else %}
'price': '{{ item.line_price }}',
{% endif %}
'quantity': '{{ item.quantity }}'
},
{% endfor %}
]
});
{% endif%}
</script>