Ecommerce Analytics Setup: GA4, Server-Side Tracking and Shopify
Good ecommerce analytics uses Shopify as the order truth, GA4 for behavior and server-side events for ad platforms, with a weekly check that catches tracking gaps fast.
Ecommerce analytics you can trust starts with one rule: Shopify orders are the truth. Use GA4 for behavior, like where people come from and where they drop off. Use the ad platforms' own pixels, backed by server-side events, to feed their algorithms. Then check every week that the three tell a story that adds up.
Most stores have the tools and still can't answer basic questions. Which channel brought new customers last month? Why did conversion rate fall on Tuesday? Is Meta really driving those sales? The problem is rarely the tool. It's that nobody decided which number is the truth for which question, and nobody checks when tracking breaks.
This playbook covers the three-layer setup, GA4 on Shopify step by step, the events that matter, consent, server-side tracking and when it's worth it, how to reconcile numbers with a worked example, a weekly dashboard and the mistakes that quietly ruin data.
Key takeaways
- Shopify is the order truth. Revenue, orders and new customers come from Shopify, never from GA4 or ad platforms.
- GA4 is for behavior. Use it for traffic sources, funnels and drop-off, not for exact revenue.
- Ad platforms need clean signal. App pixels plus server-side events with deduplication.
- Consent changes the count. Visitors who decline tracking won't show up in browser data.
- Check weekly. GA4 purchases as a share of Shopify orders is your tracking smoke alarm.
14
Months, the longest event data retention on a standard GA4 property
Google Analytics Help
48 hours
Meta's window for removing duplicate pixel and server events
Meta for Developers
78%
GA4 purchases as a share of Shopify orders in my worked example
Worked example
What does good ecommerce analytics look like?
Good analytics answers three kinds of questions, and each comes from a different place. Money questions, like revenue and orders, come from your store. Behavior questions, like traffic sources and funnel drop-off, come from your analytics tool. Ad questions, like which campaign to scale, come from the ad platforms, fed with the best signal you can send them.


Here's the stack I'd build, from the bottom up:
| Layer | Tool | The question it answers |
|---|---|---|
| Source of truth | Shopify orders and reports | How much did the store sell, to whom? |
| Consent | Cookie banner and consent mode | What is the store allowed to track? |
| Collection | Shopify app pixels, Google tag, server events | What happened on the site? |
| Reporting | GA4, ad platforms | Where did people come from and where did they stop? |
| Decisions | One weekly dashboard | What changes this week? |
The mistake is mixing layers. A store owner pulls revenue from GA4, compares it to Meta's reported sales and wonders why nothing matches. They were never meant to match.
How do you set up GA4 on Shopify?
Shopify's help page on migrating to Google Analytics 4 describes the method: connect through the Google and YouTube sales channel app. You need the editor role on the Google Analytics account. The steps:
- Create a GA4 property. Set the time zone and currency to match your store.
- Create a web data stream. Copy the tag ID.
- Install the Google and YouTube app and follow Google's tag setup steps inside it.
- Take the store out of private mode. Shopify's GA4 setup page notes that GA can't track events until you deactivate private mode.
- Remove old tags. Delete hard-coded Google tags from your theme files. Two tags means double-counted purchases.
- Place a test order. Then watch it arrive in GA4's real-time report.
Two settings to change on day one. First, set event data retention to the longest option. Google's data retention help page says standard properties can keep event data for 2 or 14 months. Pick 14. The setting only affects explorations and funnel reports, not standard reports, but those are the reports you'll want for year-over-year analysis. Second, link Google Ads and Merchant Center so your Google Shopping ads can use GA4 data.
If you also run a B2B side, the setup differs. The guide to GA4 for B2B SaaS covers lead events and CRM feedback instead of purchases.
Which events should an online store track?
Track the steps of buying, and not much else at first. Google's list of recommended events for online sales includes view_item_list, select_item, view_item, add_to_cart, remove_from_cart, view_cart, begin_checkout, add_shipping_info, add_payment_info, purchase and refund, plus promotion and wishlist events.
The core funnel needs five of them. This is the backbone of your event tracking:
| Event | What it tells you | Common failure |
|---|---|---|
| view_item | Product page reach | Fires twice on themes with quick view |
| add_to_cart | Interest | Misses carts added from collection pages |
| begin_checkout | Intent | Missing when checkout is on a different setup |
| add_payment_info | Commitment | Often skipped by express wallets |
| purchase | The sale | Duplicates on thank-you page reloads |
The purchase event must carry the order value, currency and a unique transaction ID. That ID is what stops the same order from counting twice when someone reloads the order status page.
Should you add custom events?
Only when they answer a real question. Good ones for stores: newsletter signup, quiz completed, size guide opened, search used. Each one should tie to a decision. "We track size guide opens because we suspect fit questions block sales on two product lines." If you can't write that sentence, skip the event.
How do Shopify pixels and customer events work?
Shopify handles tracking scripts through pixels, managed in the Customer events section of your admin. Shopify's how pixels work page explains two kinds. App pixels come from marketing apps, like the Google and YouTube or Facebook and Instagram channels. Custom pixels are code a developer adds by hand. Shopify recommends app pixels when possible.
Pixels run in a sandbox, an isolated space that can't touch the rest of the page. That has real limits. The same page says sandboxed pixels can't scrape the page for things like emails, outbound link clicks, scroll depth or heatmap data. It also says Google Tag Manager loaded as a custom pixel has the same sandbox limits. So if your old setup relied on reading the page, it may break.
If you still have scripts in old places, Shopify's migrating pixels page lists where they tend to live: theme.liquid, checkout.liquid on Shopify Plus, and Additional scripts in checkout settings. It says to move them to an app pixel or, when no app fits, a custom pixel.
How does consent change your numbers?
Consent decides what you may track, and it changes your counts. Shopify's pixel page says that in markets that require consent, usually the EEA and UK, web pixels run only after visitors grant the permissions set for that pixel. New pixels need marketing and analytics permissions by default. So a visitor who declines the banner never shows up in browser-based tracking.
Google's side is consent mode. Google's consent mode help page describes two setups. In basic mode, Google tags stay blocked until the visitor consents, and you get no modeled data for people who decline. In advanced mode, tags load first and send cookieless pings when consent is declined, which lets GA4 use behavioral modeling to fill gaps.
What this means in practice:
- Your GA4 numbers will run below Shopify orders. That's expected.
- The gap will be bigger in regions with strict consent rules.
- A sudden change in the gap often means the banner or consent setup changed.
This isn't legal advice. Get counsel to sign off on your banner and consent setup for the markets you sell in.
What is server-side tracking and when is it worth it?
Server-side tracking sends events from a server instead of only from the shopper's browser. Browser tracking misses events when ad blockers, browser privacy features or declined consent stop the script. A server event can carry the order data your store already has.
There are two common forms for stores:
- Platform APIs. Each ad platform has a server channel. Meta's is the Conversions API. Many Shopify ad apps offer it as a setting.
- A server-side tag container. Google Tag Manager can run a server container. Google's server-side tagging page lists the benefits as page performance, more detailed privacy controls and better data quality. It lists Cloud Run, App Engine or a manual setup as hosting options, and says to set up your own domain for the full benefit.
How do you avoid counting a sale twice?
If you send the same purchase from the browser and the server, the platform must know they're one event. Meta's guide on deduplicating pixel and server events says the pixel's event ID must match the server's event_id, and the event names must match. It also says duplicates are only removed when they arrive within 48 hours of the first event with that ID. The practical rule: use the order ID as the event ID on both sides.
Is it worth it for your store?
Here's my decision rule:
| Your situation | Do this |
|---|---|
| Under a few thousand a month in ad spend | App pixels with the platform's built-in server option, if offered |
| Steady paid spend on Meta and Google | Turn on each platform's server events through its Shopify app |
| Heavy spend, many platforms, a developer on hand | Server-side tag container on your own subdomain |
| Offline or phone sales that ads drove | Send those as offline conversions |
The offline conversion sync playbook covers that last row. For order data you control end to end, Shopify webhooks can push every order to your own systems.
How should you tag your traffic?
Every link you control should carry UTM parameters: emails, SMS, influencer links, organic social and partner links. Without them, GA4 lumps that traffic into direct or referral, and you can't tell which email drove sales.
Set a naming rule and stick to it. Lowercase, no spaces, one name per source. "email" not "Email" and "e-mail." Build links with a UTM builder so nobody types them by hand. Most email tools add UTMs automatically, so check their settings before adding your own and creating a mess.
UTM NAMING RULE
utm_source: where it came from (klaviyo, instagram, creator-name)
utm_medium: the channel type (email, sms, social, affiliate, cpc)
utm_campaign: the campaign (bfcm-2026, welcome-flow)
utm_content: the version (hero-image, text-link)
All lowercase, hyphens not spaces, no dates in source or medium.
Worked example: reconciling a month of orders
Here's what a healthy month can look like. Every number is an assumption for a made-up store.


Shopify shows 1,000 orders for the month. GA4 shows 780 purchases. Meta reports 520 purchases it takes credit for. Google Ads reports 430.
| Source | Orders counted | Share of Shopify orders |
|---|---|---|
| Shopify | 1,000 | 100% |
| GA4 purchases | 780 | 78% |
| Meta-attributed | 520 | 52% |
| Google Ads-attributed | 430 | 43% |
Read it like this. GA4 sees 78% of orders. The rest were people who declined tracking, used blockers or paid through a flow the tag missed. That's a normal-looking gap, as long as it's steady week to week.
Meta and Google together claim 950 orders. That's 95% of all orders, from two of several channels. Both are counting sales they touched within their own attribution window, including sales that email, search and word of mouth also touched. Neither is lying. They just each count from their own point of view.
The guide to MER vs ROAS goes deeper on blended return versus platform return on ad spend. When you need proof that a channel adds sales, run an incrementality test.
What does the funnel look like in GA4?
In the same made-up month, GA4 shows 20,000 view_item events, 2,400 add_to_cart, 1,300 begin_checkout and 780 purchases. That's 12% of product views reaching cart and 60% of checkouts finishing. Plug your own numbers into the funnel conversion calculator to see which step leaks most. If it's checkout, the checkout optimization guide is the next read.


What should go on the weekly dashboard?
One page, checked every Monday. If it takes more than ten minutes to read, it won't get read. These are the weekly KPIs I'd put on it:
| Metric | Source | Why it's there |
|---|---|---|
| Orders, revenue, new customers | Shopify | The money truth |
| Contribution after ad spend | Shopify plus ad accounts | Whether growth makes money |
| Blended return (revenue / total ad spend) | Shopify plus ad accounts | Whether marketing pays overall |
| Conversion rate and checkout drop-off | GA4 | Where the site leaks |
| Top traffic sources by new customers | GA4 | What to feed |
| GA4 purchases / Shopify orders | Both | Tracking health check |
The last row is the smoke alarm. If it moves from 78% to 55% in a week, something broke. Check theme changes, app installs and the consent banner first.
The contribution line needs cost data. The guide to contribution margin for ecommerce shows how to build it.
When do you need a data warehouse?
Most small stores don't. Shopify reports, GA4 and a spreadsheet get you far. A data warehouse earns its keep when you sell on several channels, want customer-level history across all of them or need models your tools can't run. Start with the dashboard. Move to a warehouse when a real question can't be answered without one.
How should you handle attribution?
Accept that no model is right and pick one for each job. Last-touch attribution in GA4 is fine for comparing email to paid search week over week. Platform numbers are fine for moving budget inside a platform. Blended return is fine for the overall budget.
Add one cheap source of truth: a post-purchase survey asking "How did you hear about us?" That's self-reported attribution, and it catches word of mouth, podcasts and creators that no pixel sees. When the survey and the pixels disagree, dig in.
What are the most common analytics mistakes?
- Two Google tags. The app plus an old theme tag doubles purchases.
- Revenue from GA4. It will always run below Shopify. Use Shopify for money.
- Data retention left short. Explorations lose history after 2 months unless you change it.
- No UTMs on email and SMS. Owned channels show up as direct traffic.
- Server events without dedup. Meta counts the sale twice and its numbers jump.
- Nobody checks. Tracking breaks after a theme update and nobody notices for a month.
- Too many apps. Every tracking app adds scripts. The Shopify apps stack guide covers how to keep it lean.
A setup checklist you can copy
GA4
[ ] Property time zone and currency match Shopify
[ ] Connected through the Google and YouTube app
[ ] Old hard-coded Google tags removed from theme
[ ] Event data retention set to 14 months
[ ] Test order seen in real-time report
[ ] Google Ads and Merchant Center linked
PIXELS AND CONSENT
[ ] One app pixel per ad platform, no duplicate custom pixels
[ ] Consent banner live where required, signed off by counsel
[ ] Consent mode set up, basic or advanced, on purpose
SERVER EVENTS
[ ] Platform server events on for main ad platforms
[ ] Order ID used as event ID for deduplication
TAGGING AND REPORTING
[ ] UTM naming rule written down
[ ] Weekly dashboard with GA4 / Shopify order ratio
[ ] Post-purchase "how did you hear about us" survey
For ad accounts that need clean signal, see how campaigns use it in Advantage+ shopping campaigns. And once tracking is clean, the Shopify conversion rate optimization guide shows what to fix first.
What should you do this week?
If you'd rather hand off the setup, that's part of our paid media and ecommerce store management work. Either way, conversion tracking is the first thing I check.
Clean analytics isn't about more tools. It's about knowing which number answers which question, and noticing the day one of them breaks.
FAQ
Why doesn't GA4 match my Shopify orders?
They count different things. Shopify records every order. GA4 only records a purchase when its tag runs and the visitor's consent allows it, so ad blockers, declined cookie banners and broken tags all cause gaps. Some gap is normal. Track it weekly as a percentage, and look into any sudden jump, because that usually means something broke.
What is the best way to connect GA4 to Shopify?
For most stores, use Shopify's Google and YouTube app, which is the method Shopify's own help center describes. You create a GA4 property and web data stream, then connect the tag through the app. Remove any old hard-coded Google tags from your theme so purchases don't get counted twice.
Do I need server-side tracking for my store?
Not on day one. Get the basics right first: one clean GA4 setup, app pixels for each ad platform and a weekly check against Shopify orders. Server-side tracking starts to pay when you spend enough on ads that better signal quality changes results, or when browser tracking misses too many purchases.
How long does GA4 keep my data?
Standard GA4 properties let you set event data retention to 2 or 14 months. That setting only affects explorations and funnel reports, not the standard reports. Set it to 14 months on day one so you can compare this year to last year in explorations, and export raw data if you need a longer history.
Which numbers should a store owner check every week?
Orders, revenue and new customers from Shopify. Spend and blended return from your ad accounts. Conversion rate and checkout drop-off from GA4. And the tracking health check: GA4 purchases as a share of Shopify orders. Keep it to one page so you actually look at it every week.
Should I trust Meta or Google Ads conversion numbers?
Use them to steer each platform, not to judge your whole business. Each platform counts the sales it touched within its own window, so their totals overlap and often add up to more than your real orders. Judge total marketing with Shopify revenue against total spend, and test channels with holdouts when the stakes are high.
More like this
E-commerceAnalyticsGlossary: Consent Mode, Data Layer, First-Party Data, Google Analytics 4 (GA4), Micro-Conversion, Third-Party Cookies