Skip to content

Instantly share code, notes, and snippets.

This is a cool way to add a gist!
@vvastdev
vvastdev / gtag.liquid
Created April 19, 2022 14:30
gtag based implementation of GA4 dataLayer population
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-5GE0TR6RDZ"></script>
<script>
let args = {
'event': "orderconfirmation",
'discount': '{{ order.total_discounts }}',
'shippingPrice': '{{ order.shipping_price | money_without_currency | replace: ",", "." }}',
'transactionTax': '{{ order.tax_price | money_without_currency | replace: ",", "." }}',
'transactionSubtotal': '{{ order.subtotal_price | money_without_currency | replace: ",", "." }}',
@vvastdev
vvastdev / onetrust-shopify-callback.js
Created October 20, 2021 11:05
Callback to Shopify privacy API on OneTrust banner interaction, passing boolean based on OT tracking consent codes
<script>
const performanceCookieCategory = '2,';
function waitForOneTrust() {
hasOneTrustLoaded();
let attempts = 0;
const interval = setInterval(function () {
require('isomorphic-fetch');
const dotenv = require('dotenv');
const Koa = require('koa');
const next = require('next');
const { default: createShopifyAuth } = require('@shopify/koa-shopify-auth');
const { verifyRequest } = require('@shopify/koa-shopify-auth');
const session = require('koa-session');
dotenv.config();
@vvastdev
vvastdev / product.js
Last active January 24, 2020 16:14
product.js variant availability handling
//called in initVariants
_handleColourAvailability: function(data) {
if(this.variantRadios){
var variants = data.product.variants;
var coloursAvailable = {};
variants.forEach( variant => {
if(variant.available){
coloursAvailable[variant.option1] = true;
}