Free, copy-paste Shopify Liquid snippets and JavaScript scripts — battle-tested solutions for the most common Shopify development problems. No apps required.
Built and maintained by Aumlytics — analytics & Shopify development specialists.
Every week, hundreds of Shopify merchants and developers ask the same questions on r/shopify and r/shopifydev:
- "How do I track GA4 purchases after checkout.liquid was deprecated?"
- "How do I show a free shipping progress bar in my cart?"
- "How do I display variant-specific metafields without a page refresh?"
These snippets are the answers — production-ready, well-commented, and updated for Shopify 2025+.
| # | Snippet | What It Solves | Complexity |
|---|---|---|---|
| 01 | GA4 Purchase Event — Custom Pixel | Track purchases after checkout.liquid deprecation |
⭐⭐ |
| 02 | GTM via Custom Pixel + dataLayer Bridge | Load GTM inside Shopify's sandboxed pixel environment | ⭐⭐⭐ |
| 03 | Variant Metafield Display (Dynamic) | Update metafield content on variant switch without page reload | ⭐⭐ |
| 04 | AJAX Cart Drawer + Free Shipping Bar | Slide-out cart with animated progress bar toward free shipping | ⭐⭐⭐ |
| 05 | Sale Badge + Discount % on Product Cards | Show "Save 30%" badges calculated from compare_at_price | ⭐ |
| 06 | Sticky Add-to-Cart Bar | Fixed ATC bar that appears when the main button scrolls out of view | ⭐⭐ |
| 07 | Color Swatches + Variant Image Swap | Native color swatches with live image swap on hover/click | ⭐⭐ |
| 08 | Back-in-Stock Email Capture | "Notify me" form for sold-out products — no app needed | ⭐ |
| 09 | Recently Viewed Products | localStorage-based recently viewed carousel | ⭐⭐ |
| 10 | Countdown Timer (Metafield-driven) | Sale/shipping cutoff countdown from a product metafield | ⭐⭐ |
| 11 | JSON-LD Schema (Product + Breadcrumb) | Rich results for Google — product, breadcrumb, organization | ⭐ |
| 12 | Responsive Image with srcset | Correct srcset/sizes for Shopify images — kills LCP issues | ⭐ |
| 13 | Infinite Scroll Collection Pages | Load more products automatically as users scroll — no pagination clicks | ⭐⭐ |
New snippets are added weekly, sourced from recurring questions on r/shopify and r/shopifydev.
- Browse to the snippet folder you need
- Read the
README.mdinside for setup instructions - Copy the
.liquidfile into your theme'ssnippets/folder {% render 'snippet-name' %}where needed- Copy any
.jsfile intoassets/and reference it with{{ 'snippet-name.js' | asset_url | script_tag }}
- Shopify Online Store 2.0 themes (Dawn, Sense, Refresh, Crave, Craft, Horizon)
- Shopify Liquid (latest)
- Checkout Extensibility (post-August 2024)
- Shopify Markets / multi-currency
- Legacy themes (Debut, Brooklyn) may need minor adjustments
Found a bug? Have a snippet that solves a common problem? PRs welcome.
- Fork the repo
- Create a folder in
snippets/your-snippet-name/ - Add
README.md, your.liquidfile, and any.jsfiles - Open a PR with a description of what it solves
These snippets scratch the surface. If you need a full GA4 + GTM implementation, custom Shopify app development, Amazon SP-API integrations, or AI agent automation for your store — book a free consultation with Aumlytics.
We're practitioners who implement these solutions daily for e-commerce brands.
MIT — free to use in any project, commercial or personal.
Maintained by Aumlytics · @aumlytics on X