Created
August 10, 2022 12:57
-
-
Save thebigtine/ec89706dfecc33529b2b8faf9b13ecf9 to your computer and use it in GitHub Desktop.
Shopify Google tracking code
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
gtag("event", "purchase", { | |
transaction_id: "{{ order.order_number }}", | |
affiliation: "Google Merchandise Store", | |
value: {{ total_price | times: 0.01 }}, | |
tax: {{ tax_price | times: 0.01 }}, | |
shipping: {{ shipping_price | times: 0.01 }}, | |
currency: "{{ order.currency }}", | |
coupon: "{{ order.discount_application.title }}", // needs testing | |
items: [ | |
{% for line_item in line_items %}{ | |
item_id: "{{ line_item.product_id }}", | |
item_name: "{{ line_item.title | remove: "'" | remove: '"' }}", | |
affiliation: "Google Merchandise Store", | |
coupon: "{{ line_item.discount_allocation.discount_application.title }}", // needs testing | |
currency: "{{ order.currency }}", | |
discount: {{ line_item.line_level_total_discount }}, | |
index: {{ forloop.index }}, // needs testing | |
item_brand: "{{ line_item.product.vendor }}", | |
item_category: "{{ line_item.product.type }}", | |
//item_category2: "Adult", | |
//item_category3: "Shirts", | |
//item_category4: "Crew", | |
//item_category5: "Short sleeve", | |
//item_list_id: "related_products", | |
//item_list_name: "Related Products", | |
item_variant: "{{ line_item.variant.title }}", | |
//location_id: "ChIJIQBpAG2ahYAR_6128GcTUEo", | |
price: {{ line_item.final_price | times: 0.01 }}, | |
quantity: {{ line_item.quantity }} | |
},{% endfor %} | |
], | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment