Skip to content

Instantly share code, notes, and snippets.

@lstude
Created October 25, 2019 17:45
Show Gist options
  • Save lstude/a8e55aef89bcbd4f5adae5ca748409e5 to your computer and use it in GitHub Desktop.
Save lstude/a8e55aef89bcbd4f5adae5ca748409e5 to your computer and use it in GitHub Desktop.
Bebe checkout step labels - gtag.js
<script>
/**
* Google Analytics Enhanced Ecommerce - Checkout Labels
* - to be fired on all Checkout pages (after GA tag)
*/
// looks at `Shopify.Checkout` to determine which checkout step we're on, then pushes that step info to Google Enhanced Ecommerce for Checkout Labeling
(function(){
if (window.gtag && Shopify.Checkout) {
var ShopifyCheckoutstep = Shopify.Checkout.step;
switch (ShopifyCheckoutstep) {
case 'contact_information':
// Step 2: Shipping Addressss
gtag('event', 'checkout_progress', {
'send_to': 'UA-41750265-8',
'event_category': 'Checkout',
'event_action': 'Shipping Address',
'checkout_step': 2
});
break;
case 'shipping_method':
// Step 3: Shipping Method
gtag('event', 'checkout_progress', {
'send_to': 'UA-41750265-8',
'event_category': 'Checkout',
'event_action': 'Shipping Method',
'checkout_step': 3
});
break;
case 'payment_method':
// Step 4: Payment Method
gtag('event', 'checkout_progress', {
'send_to': 'UA-41750265-8',
'event_category': 'Checkout',
'event_action': 'Payment Method',
'checkout_step': 4
});
break;
case 'thank_you':
// Step 6: Thank You / Confirmation
gtag('event', 'checkout_progress', {
'send_to': 'UA-41750265-8',
'event_category': 'Checkout',
'event_action': 'Thank You',
'checkout_step': 5
});
break;
}
}
})()
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment