Skip to content

Instantly share code, notes, and snippets.

@samba
samba / shopify.datalayer.html
Last active January 20, 2025 22:07
Shopify DataLayer Checkout
{% if first_time_accessed %}
<script>
(function(dataLayer){
var customer_type = ({{customer.orders_count}} > 1) ? 'repeatcustomer' : 'newcustomer';
var discounts = "{{ order.discounts | map: 'code' | join: ',' | upcase}}";
function strip(text){
return text.replace(/\s+/, ' ').replace(/^\s+/, '').replace(/\s+$/, '');
}
@willbroderick
willbroderick / seo-hacks.liquid
Last active March 22, 2021 16:50
Shopify SEO - attempt to avoid duplicate meta descriptions
Two changes to make in theme.liquid
It will add 'Page 2' etc to the meta description for collection/blog pages, to make those different.
It adds a canonical tag for tag-filtered pages, back to the base collection/blog page.
*** This is the standard meta description code: ***
{% if page_description %}
<meta name="description" content="{{ page_description | escape }}" />
{% endif %}