k-sync
Back to blog

Setting up Google analytics 4 on Shopify after WooCommerce migration (2026)

How to set up GA4 on Shopify after migrating from WooCommerce — configuring ecommerce tracking, preserving historical data, comparing pre/post migration metrics, and avoiding data gaps.

·By k-sync
5 min read · 1,003 words

One of the first post-migration tasks is connecting Google Analytics 4 to your new Shopify store. This guide covers how to do that properly — preserving historical context, configuring ecommerce tracking, and avoiding data gaps that make post-migration performance comparison difficult.

Should you use the same GA4 property or create a new one?

Use the same GA4 property you used on WooCommerce. Reasons:

Exception: if your WooCommerce and Shopify stores are actually different products/brands, or if you're moving to a different domain, create a new property. But for a standard platform migration of the same store, use the same property.

Method 1: Shopify's native Google channel (simplest)

Shopify has a native Google channel that handles basic GA4 + Google Ads integration:

  1. In Shopify Admin, go to Sales channels → Add sales channel → Google
  2. Connect your Google account and select your GA4 property
  3. Enable "Web pixel" option for Shopify
  4. Shopify will automatically add the GA4 base tag and basic ecommerce events

What this method tracks: Page views, session data, and basic purchase events (purchase, add_to_cart, begin_checkout, view_item).

What this method misses: Some advanced ecommerce events (view_item_list, select_item, search), custom event tracking, and some data that requires Customer Events API or GTM for full coverage.

Method 2: Customer Events (Shopify's custom tracking system)

For more granular tracking, use Shopify's Customer Events (formerly Shopify Pixels):

  1. In Shopify Admin → Settings → Customer events
  2. Add a pixel → Custom pixel
  3. Paste your GA4 tracking code with event listeners for Shopify's standard events

Shopify fires standard events (page_viewed, cart_viewed, checkout_started, checkout_completed, product_viewed, collection_viewed, search_submitted) that you can forward to GA4.

Example pixel code for GA4 via Customer Events:

// Load GA4
(function(){
  var script = document.createElement('script');
  script.src = 'https://www.googletagmanager.com/gtag/js?id=G-XXXXXXXXXX';
  document.head.appendChild(script);
})();
window.dataLayer = window.dataLayer || [];
function gtag(){ dataLayer.push(arguments); }
gtag('js', new Date());
gtag('config', 'G-XXXXXXXXXX');

// Shopify standard events → GA4
analytics.subscribe('page_viewed', (event) => {
  gtag('event', 'page_view', { page_location: event.context.window.location.href });
});
analytics.subscribe('checkout_completed', (event) => {
  const order = event.data.checkout;
  gtag('event', 'purchase', {
    transaction_id: order.order.id,
    value: parseFloat(order.totalPrice.amount),
    currency: order.totalPrice.currencyCode,
    items: order.lineItems.map(item => ({
      item_id: item.variant.sku,
      item_name: item.title,
      price: parseFloat(item.variant.price.amount),
      quantity: item.quantity,
    }))
  });
});
// Add more events as needed

Method 3: Google Tag Manager (most flexible)

If you used GTM on WooCommerce, continue using it on Shopify:

  1. In Shopify Admin, go to Online Store → Themes → Edit code
  2. Add the GTM snippet to theme.liquid (in <head> and after <body>)
  3. Or use a Shopify GTM app (e.g., "GTM & GA4 + Google Ads" from Shopify App Store) for easier management

GTM on Shopify has some quirks:

Configuring cross-domain tracking (important for checkout)

Shopify checkout runs on yourstore.myshopify.com or checkout.shopify.com — different from your main domain. GA4 needs cross-domain tracking to attribute conversions correctly.

In GA4 Admin → Data Streams → your stream → Configure tag settings → Configure your domains:

Without cross-domain tracking, GA4 counts every checkout page view as a new session from a new user, inflating session counts and breaking attribution.

Preserving your WooCommerce historical data

GA4 data from WooCommerce doesn't disappear when you migrate — it stays in your GA4 property. However:

Best practice: export a snapshot of key metrics before going live on Shopify. Create a custom report in GA4 and export/save:

This becomes your "pre-migration baseline" for comparison 30/60/90 days post-launch.

What to monitor after going live on Shopify

First week

First month

3-month mark

Quick GA4 audit after going live

Run this 24 hours after DNS cutover:

GA4 setup is one of those tasks that's easy to do quickly but hard to redo if done wrong. Take the time to validate that ecommerce tracking is correct on day 1 — incorrect tracking during the first 30 days creates gaps that affect reporting for months.

Migrate your store with k-sync

Connect your WooCommerce store, validate your products, and push to Shopify in minutes. Free for up to 50 products.

Get started free

Related reading

Browse all migration guides