Created
July 2, 2021 17:04
-
-
Save avcohen/0346492c44ade635c2349ec28258c568 to your computer and use it in GitHub Desktop.
Heed - Shopify Checkout
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
<!-- GTM INIT--> | |
<script type="text/javascript"> | |
(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= | |
'//www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f); | |
})(window,document,'script','dataLayer','GTM-K5SMW5F'); | |
function gtag(){dataLayer.push(arguments);}; | |
function track(payload){dataLayer.push(payload);}; | |
gtag('set', 'linker', {'domains': ['shop.heedfoods.com', 'heedfoods.myshopify.com', 'www.heedfoods.com']}); | |
gtag('config', 'GTM-K5SMW5F'); | |
</script> | |
<!-- FRIENDBUY INIT--> | |
<script type="text/javascript"> | |
(function (f, r, n, d, b, y) { b = f.createElement(r), y = f.getElementsByTagName(r)[0];b.async = 1;b.src = n;y.parentNode.insertBefore(b, y); })(document, 'script', '//djnf6e5yyirys.cloudfront.net/js/friendbuy.min.js'); | |
</script> | |
<!-- SHARE SALE INIT --> | |
<script src='https://www.dwin1.com/19038.js' type='text/javascript' defer='defer'></script> | |
<meta name='referrer' content='unsafe-url'> | |
<!-- GTM CONFIG --> | |
{% if first_time_accessed %} | |
<script type="text/javascript"> | |
let friendBuyProducts = new Array(); | |
{% for line in line_items %} | |
friendBuyProducts.push( | |
{ | |
sku: '{{ line.sku or line.product.id }}', | |
price: '{{ line.price | money_without_currency }}', | |
quantity: '{{ line.quantity }}' | |
} | |
); | |
{% endfor %} | |
window['friendbuy'] = window['friendbuy'] || []; | |
window['friendbuy'].push(['site', 'site-aed8e96f-www.heedfoods.com']); | |
window['friendbuy'].push(['track', 'customer', | |
{ | |
id: '{{ customer.id }}', | |
email: '{{ customer.email }}', | |
first_name: '{{ customer.first_name }}', | |
last_name: '{{ customer.last_name }}' | |
} | |
]); | |
window['friendbuy'].push(['track', 'products', friendBuyProducts]); | |
window['friendbuy'].push(['track', 'order', | |
{ | |
id: '{{ checkout.order_id }}', | |
amount: '{{ total_price | money_without_currency }}', | |
coupon_code: '{% if order.discounts|length > 0 %}{{order.discounts[0].code}}{% endif %}', | |
email: '{{ customer.email }}', | |
new_customer: {% if order.customer.orders_count == 1 %}true{% else %}false{% endif %} | |
} | |
]); | |
</script> | |
<!-- ADSHOPPERS --> | |
<script type="text/javascript"> | |
var AddShoppersWidgetOptions = { 'loadCss': false }; | |
AddShoppersConversion = { | |
order_id: " {{ order.order_number }}", // replace <order id> with the correct variable | |
value: "{{ order.total_price | money_without_currency | remove: ',' }}", // replace <order value> with the correct variable | |
email: "{{ checkout.email }}" // replace <user email> with the correct variable | |
}; | |
(!function(){ | |
var t=document.createElement("script"); | |
t.type="text/javascript", | |
t.async=!0, | |
t.id="AddShoppers", | |
t.src="https://shop.pe/widget/widget_async.js#5f878284bbddbd7bcfc493c8", | |
document.getElementsByTagName("head")[0].appendChild(t) | |
}()); | |
AddShoppersWidget.track_conv(); | |
</script> | |
<!-- GTM --> | |
<script type="text/javascript"> | |
var products = new Array(); | |
{% for line_item in order.line_items %} | |
products.push({ | |
name: '{{ line_item.product.title }}', | |
id: {{ line_item.product_id }}, | |
price: {{ line_item.final_price | money_without_currency | remove: ',' }}, | |
brand: 'HeedFoods', | |
variant: '{{ line_item.variant.title }}', | |
quantity: {{ line_item.quantity }} | |
}) | |
{% endfor %} | |
var orderId = '{{ order.order_number | append: "" | remove: "#" }}'.replace("#", ""); | |
track({ | |
event: 'track', | |
ecommerce: { | |
purchase: { | |
actionField: { | |
id: orderId, | |
affiliation: 'Online Store', | |
revenue: {{ order.total_price | money_without_currency | remove: ',' }}, | |
tax: {{ order.tax_price | money_without_currency | remove: ',' }}, | |
shipping: {{ order.shipping_price | money_without_currency | remove: ',' }}, | |
coupon: '{{ order.discount_applications[0].title }}', | |
}, | |
products: products, | |
}, | |
customer: { | |
id: {{ customer.id }}, | |
email: '{{ customer.email }}', | |
first_name: '{{ customer.first_name }}', | |
last_name: '{{ customer.last_name }}' | |
}, | |
}, | |
eventDetail: { | |
category: 'Ecommerce', | |
action: 'CompleteCheckoutShopify', | |
label: 'Value', | |
value: {{ order.total_price | money_without_currency | remove: ',' }} | |
} | |
}); | |
</script> | |
<!-- SHARE SALE --> | |
<img src='https://shareasale.com/sale.cfm?v=Shopify3%2E3&{% assign giftamount = checkout.gift_cards_amount|money_without_currency | remove: ',' %}{% assign subtotal = subtotal_price | money_without_currency | remove: ',' %}{% assign total = subtotal | minus: giftamount %}amount={{total}}&tracking={{order_name|handleize}}&transtype=sale&merchantID=88209¤cy={{ shop.currency }}&skulist={% for line_item in line_items %}{% if forloop.last == true %}{{ line_item.sku }}{% else %}{{ line_item.sku | append: ','}}{% endif %}{% endfor %}{% if giftamount %}{% if checkout.discounts %}{% assign discount_total = checkout.discounts_amount | divided_by: 100 | plus: giftamount %}{% else %}{% assign discount_total = giftamount %}{% endif %}{% else %}{% assign discount_total = checkout.discounts_amount %}{% endif %}{% assign dtotal = discount_total | times: 100 %}&pricelist={% if checkout.discounts %}{% for line_item in line_items %}{% if line_item.price > 0 %}{% assign total_cartprice = checkout.subtotal_price | plus: checkout.discounts_amount %}{% assign ratio = dtotal | divided_by: total_cartprice %}{% assign ratioless = 1 | minus: ratio %}{% assign final_item_price = line_item.price | times: ratioless %}{% if forloop.last == true %}{{ final_item_price | money_without_currency | remove: ','}}{% else %}{{ final_item_price | money_without_currency | remove: ',' | append: ','}}{% endif %}{% else %}{% if forloop.last == true %}{{ line_item.price | money_without_currency | remove: ','}}{% else %}{{ line_item.price | money_without_currency | remove: ',' | append: ','}}{% endif %}{% endif %}{% endfor %}{% else %}{% for item in line_items %}{% assign total_cartprice = checkout.subtotal_price %}{% assign ratio = dtotal | divided_by: total_cartprice %}{% assign ratioless = 1 | minus: ratio %}{% assign final_item_price = line_item.price | times: ratioless %}{% if forloop.last == true %}{{ final_item_price | money_without_currency | remove: ',' }}{% else %}{{final_item_price | money_without_currency | remove: ',' | append: ','}}{% endif %}{% endfor %}{% endif %}&quantitylist={% for line_item in line_items %}{% if forloop.last == true %}{{ line_item.quantity }}{% else %}{{ line_item.quantity | append: ','}}{% endif %}{% endfor %}&couponcode={% for discount in checkout.discounts %}{% if forloop.last == true %}{{ discount.code }}{% else %}{{ discount.code | append: ',' }}{% endif %}{% endfor %}{% if customer.orders_count > 1 %}&newcustomer=0{% elsif customer.orders_count <= 1 %}&newcustomer=1{% else %}&newcustomer={% endif %}' width='1' height='1'><meta name='referrer'content='origin'> | |
{% endif %} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment