Shopify Google Analytics Checkout Behavior Analysis

Shopify Google Analytics Checkout Behavior Analysis

How to set up Enhanced Ecommerce Checkout Behavior Analysis on Shopify

Shopify has an out of the box Google Analytics and Enhanced Ecommerce setup. A detail guide on how to set this up is here: Setting up Google Analytics.

However the Shopify integration does not handle the Checkout Behavior Analysis implementation. The Checkout Behavior Analysis is an important checkout-funnel visualization report that lets you see how successfully your users moved through your checkout process.

If you are on Shopify Plus you can enable this data with the following code added to checkout.liquid:

<script>
  (function CheckoutEnhancedEcommerce() {
    'use strict';
    window.addEventListener('load', init);
    function init() {
      switch (Shopify.Checkout.step) {
        case 'contact_information':
          ga('require', 'ec');
          ga('ec:setAction', 'checkout', {
            'step': 1,
            'option': 'contact_information'
          });
          ga('send', 'event', 'checkout', 'contact information');
          break; 
        case 'shipping_method':
          ga('require', 'ec');
          ga('ec:setAction', 'checkout', {
            'step': 2,
            'option': 'shipping_method'
          });
          ga('send', 'event', 'checkout', 'shipping method');
          break; 
        case 'payment_method':
          ga('require', 'ec');
          ga('ec:setAction', 'checkout', {
            'step': 3,
            'option': 'payment_method'
          });
          ga('send', 'event', 'checkout', 'payment method');
          break;
        case 'thank_you':
          ga('require', 'ec');
          ga('ec:setAction', 'checkout', {
            'step': 4,
            'option': 'thank_you'
          });
          ga('send', 'event', 'checkout', 'payment');
      }
    }
  })();
</script>