How to set up server-side tracking, step by step
Start with Shopify's Facebook & Instagram data sharing set to Enhanced or Maximum. For GA4, create a Tag Manager server container and provision it on Cloud Run. Map your own subdomain, point your Google tag at it, then test in preview and DebugView.
By Joris van Huët, Founder & CEOUpdated 8 min read
Run the numbers for your store: the free server-side tracking ROI calculator.
To set up server-side tracking, you usually start with the no-code route: switch Shopify's Facebook & Instagram data sharing to Enhanced or Maximum. For GA4 and Google Ads, create a Tag Manager server container and map it to your own subdomain. Then point your Google tag at it and test before trusting a single number.
This is the setup in the order you do it. For what server-side tracking is, and what it cannot fix, start with the plain answer.
The first four steps cover Meta on Shopify and need no code. The rest build Google's server container and need a Google Cloud billing account.
Step by step
- Write down today's numbers. Before anything changes, note last month's order count in Shopify and purchase count in GA4. Without a before, the after means nothing. Path: Shopify admin > Analytics > Reports > Orders > Orders over time, then GA4 > Reports > Engagement > Events, purchase row.
- Turn on Meta's server route in Shopify. Standard sends data through the Meta pixel alone. Enhanced and Maximum add the Conversions API. They also share customers' names, locations, emails and phone numbers to match users, so update your privacy policy. Path: Shopify admin > Sales channels > Facebook & Instagram > Settings > Data sharing settings > Customer data sharing > CHOOSE LEVEL.
- Check that Meta now gets server events. Events Manager shows browser events from the pixel next to server events from the Conversions API. Meta's rule is that server events should match or exceed the pixel's. Path: Events Manager > select your data > find Purchase > View details > Event overview.
- Make sure each purchase counts once. Meta merges a pixel event and a server event when their event IDs and event names match. Check the deduplication tab after a day of orders. Path: Events Manager > Purchase > View details > Event Deduplication.
- Create a server container. Server-side tagging lives in its own Tag Manager container, next to the one on your site. Path: Tag Manager > Accounts > overflow menu next to your account > Create Container > Target platform: Server > Create.
- Provision the tagging server. The quick route deploys to Cloud Run in Google Cloud with a testing configuration. It always uses the us-central1 region and can run only once. For servers near your shoppers, provision manually and pick the region closest to your customers. Path: setup screen > Automatically provision tagging server > choose a billing account > create the server.
- Size it for live traffic. Google says the automatic deployment suits testing limited traffic only. Its Cloud Run guide recommends at least 2 instances at about $45 a month each, and its overview says 3. Path: Google Cloud > Cloud Run > select the service > Edit & Deploy New Revision.
- Use your own domain. On the default run.app address, the tagging server sits in a third-party context and can only set JavaScript cookies. Point a subdomain such as metrics.yourstore.com at it, or a path on your main domain. Path: Tag Manager > your server container > Admin > Container Settings > Add URL. Details: custom domain configuration.
- Point your Google tag at the server. Add a Google tag: Configuration settings variable in your web container. Give it one parameter, server_container_url, set to your server's URL. Select that variable in your Google tag, fire it on Initialization - All Pages, then publish. On Shopify, Tag Manager runs as a custom pixel in the Customer events section, inside Shopify's sandbox. Path: Variables > New, then Tags > Google tag > Configuration settings.
- Preview the server container. Click Preview, then browse your store in another window. Requests and events show up on the left of the preview page. Path: Tag Manager > your server container > Preview.
- Run the health check. Open your server URL with /healthy added to the path. A working server answers with the text ok. Path: copy the URL from Admin > Container Settings, then paste it into a new browser tab.
- Watch a test order arrive in GA4. Turn on debug mode through Tag Assistant or preview mode, then place a test order. The purchase should land once in DebugView, carrying its transaction ID. Path: GA4 > Admin > Data display > DebugView.
A worked example
Take one store's export. On its Channels sheet, Direct holds 57.7% of revenue in all three views. That is the row to watch once a server goes live.
For illustration, say Shopify shows 500 orders in a month and GA4 records 425 purchases. If the numbers hold, GA4 sees 85% of orders, and 75 never reached it. A month after the switch, say the GA4 count is 465 out of another 500. If the switch works, that is 93%: 40 more purchases now arrive.
Then look at where the recovered purchases landed. Open Traffic acquisition for both months and compare Direct's share. If it falls while purchases rise, blocked visits carried real sources and the server let them through. If it holds, the recovered visits came without sources, and your tags are the next job.
Meta gets its own check. For illustration, say Events Manager shows 380 browser and 470 server Purchase events for the month. Server events beat the pixel's, which is what Meta asks for. If you add those up, Events Received shows 850, since it sums both sources without removing duplicates. Count orders in Shopify, never there.
What to check when the report looks wrong
- GA4 counts some orders twice. GA4 merges purchases that share a transaction ID, so every purchase needs one. If two setups send the same order, they must send the same ID.
- Meta shows more purchases than Shopify. Open the Event Deduplication tab first. A pixel event and a server event only merge when the event ID and event name both match.
- Server events trail the pixel. Meta asks you to adjust the Conversions API setup when pixel events come out higher. On Shopify, check that a pixel is connected under Data sharing settings.
- The preview page will not load. Check the server URL under Admin > Container Settings, then run the health check again.
- Consent choices seem ignored. Set consent mode up in the web container. Google says that is the only place it needs to live, because the Google tag passes consent to the server with each request.
- The Cloud bill jumped. Google warns that request logging can add significant charges above about 1 million requests a month. Switch it off in Google Cloud's Logs Router.
- Sessions shifted in late September 2026. Shopify changed how it measures sessions between 21 and 23 September 2026. Compare orders, not sessions, across that week.
What to do this week
- Pick the route your gap points to. Set last month's Shopify orders against GA4's purchase count from step 1. Pass: GA4 sits close, so only Meta needs the server route and the Shopify steps are the whole job. Fail: GA4 misses a big share, so plan the Google container too.
- Make the Shopify switch today. It is a settings change, not a developer project. Pass: within a day, Events Manager lists server events for Purchase. Fail: browser events only, so connect the pixel in Shopify's data sharing settings.
- Trial the Google container before paying for production. Google says a default deployment with a single server is free in most cases. Run it on your own subdomain for a week before you size it up. Pass: preview shows your store's requests and the health check says ok. Fail: nothing arrives, so recheck the server_container_url variable.
Check the homework. Your GA4 Attribution paths export already holds the evidence. Causality Engine reads that one file and shows what each channel caused next to what last-click gave it, in 1 to 2 minutes, for €99 once (excluding VAT), refundable within 30 days. Check the homework
Sources, 1 October 2026: Order reports (Shopify); Events report (Google); Facebook data sharing (Shopify); View server event details in Meta Events Manager (Meta); Handling Duplicate Pixel and Conversions API Events (Meta); Server-side tagging (Google); Set up server-side tagging with Cloud Run (automatic provisioning) (Google); Set up server-side tagging with Cloud Run (manual provisioning) (Google); Custom domain configuration (Google); Send data to server-side Tag Manager (Google); Pixels overview (Shopify); An introduction to server-side tagging (Google); Implement consent mode with server-side Tag Manager (Google); Monitor events in DebugView (Google); Minimize duplicate key events with transaction IDs (Google); Analytics discrepancies (Shopify); [GA4] Traffic acquisition report (Google)
Related answers
Frequently asked questions
Do I need Google Tag Manager for server-side tracking?
Not for Meta on Shopify. The Facebook & Instagram app's Enhanced or Maximum level sends purchases server to server without Tag Manager. For GA4 and Google Ads through your own server, Google's route is a Tag Manager server container.Can I choose where my tagging server runs?
Yes, by provisioning it manually. Google's automatic setup always places the server in the us-central1 region and can run only once. Manual setup in Google Cloud lets you pick the Cloud Run region closest to your customers.Why are purchases counted twice after going server-side?
Usually two setups send the same order. GA4 only merges purchases that share a transaction ID. Meta only merges a pixel event and a server event with the same event ID and event name. Send one ID down both routes and the double count goes.
Go deeper: Causal attribution, explained.
Sixty-second versions of these ideas: Causality Engine on YouTube Shorts.
Keep reading
Terms in this article
- AnalyticsAnalytics is the systematic computational analysis of data. It reveals customer behavior and measures campaign performance.
- AttributionAttribution identifies user actions that contribute to a desired outcome and assigns value to each. It reveals which marketing touchpoints drive conversions.
- CausalityCausality is the relationship where one event directly causes another, essential for identifying specific actions that drive desired outcomes in marketing.
- ConversionConversion is a specific, desired action a user takes in response to a marketing message, such as a purchase or a sign-up.
- Google AdsGoogle Ads is an online advertising platform where advertisers bid to display ads, service offerings, and product listings.
- Google Tag ManagerGoogle Tag Manager is a tag management system that allows you to update tracking codes and related code fragments on your website or mobile app.
- MetricsMetrics are quantifiable measures that track and assess business process status. They evaluate campaign performance and inform attribution analysis.
- Privacy PolicyPrivacy Policy is a statement disclosing how a website collects, uses, discloses, and manages customer data.