Shopify GA4 ecommerce tracking with Google Tag Manager, without an app
To set up Shopify GA4 ecommerce tracking with Google Tag Manager, you add a data layer to your store as a custom pixel under Settings → Customer events, then build one GA4 event tag in GTM for each shopping step: view_item, add_to_cart, begin_checkout, add_payment_info and purchase. Each tag sends the products as an items array, with the value and currency, and the purchase also sends the order ID as transaction_id. Then you walk through a test order and check every event in GA4's DebugView.
The video above shows the setup on a Shopify store in about 12 minutes. This post is the written version: the same steps in order, the extra events and parameters from my longer, field-by-field video, and the double-counting trap to check before you publish.
Why the built-in connection isn't enough
Shopify can connect GA4 for you through the Google & YouTube app. It sends a fixed set of events mapped from Shopify's own events: page_view, view_item, add_to_cart, begin_checkout, add_payment_info, purchase and search (Google, Shopify event parameters). Google's list for the app has no view_cart, remove_from_cart, view_item_list or add_shipping_info, and you can't choose what each event carries.
With GTM, you decide which events fire and exactly which details go with them. The same container can also run your Meta, Google Ads and TikTok tags, so every tool reads from one data layer.
The events GA4 expects from a store
GA4 has a set of recommended ecommerce events. Use their exact names: GA4 event names are case-sensitive, so Purchase is not the same event as purchase, and GA4 only fills its ecommerce reports from the recommended names.
view_itemwhen a product page is viewed. Needscurrency,valueanditems.add_to_cartwhen a product is added to the cart. Needscurrency,valueanditems.begin_checkoutwhen checkout starts. Needscurrency,valueanditems.add_payment_infowhen payment details are entered. Needscurrency,valueanditems.purchasewhen the order is placed. Needstransaction_id,currency,valueanditems.
Google marks these as required, and adds that if you send a value, the currency is needed for revenue to be worked out correctly. Every product in items needs an item_id or an item_name; Google recommends both (Google, GA4 recommended events reference).
The items array is what makes the product reports work. Without it, GA4 shows revenue but not which products earned it.
What you need
- A Google Tag Manager account with a Web container for your store.
- A GA4 property with a web data stream for your store's address.
- Access to your Shopify admin, to add a custom pixel.
- A Shopify data layer script. It runs inside Shopify's Customer Events, loads your GTM container, and pushes each shopping step into the data layer with the product, order and customer details. The video uses my free Shopify data layer script, linked in the video description. It's the same one I use in the Facebook Pixel on Shopify setup and the Google Ads conversion tracking setup, so one data layer can feed all three.
Step 1: Create your GTM container and GA4 data stream
Go to tagmanager.google.com, create an account, and add a container with your store or business name. Choose Web as the target platform. Copy the container ID, which starts with GTM-.
Then go to analytics.google.com. In Admin → Data streams, add a Web stream, enter your store's address and a stream name, and click Create and continue. Copy the Measurement ID, which starts with G-.
Two accounts, two IDs. You'll need both in the next steps.
Step 2: Add the Shopify data layer as a custom pixel
In your Shopify admin:
- Go to Settings → Customer events and open the Custom pixels tab.
- Click Add custom pixel, give it a name, such as
GTM data layer, and click Add pixel. - Under Customer privacy, set the permission. The video uses Not required, so the pixel always runs, and sets the data sale option to Data collected does not qualify as data sale. If you need visitor consent in your region, choose Required and the right purposes instead.
- Paste the data layer script into the Code box.
- Replace the placeholder container ID inside the script with your own
GTM-ID. - Click Save, then Connect.
GTM now loads through Customer Events, which means it runs on every page, checkout included. The old method of pasting GTM into theme.liquid never reached Shopify's checkout properly.
Before you build anything, see what the data layer sends. Open a product page, right-click, choose Inspect, then Console. The script logs each event there, such as view_item, with the price, currency and items. Note the event names and field names. Your triggers and variables must match them exactly.
Step 3: Set up the Google tag in GTM
In GTM, create a Constant variable that holds your G- Measurement ID. The video calls it GA4 measurement ID. Every GA4 tag will point to it, so you only type the ID once.
Then create the base tag:
- Tag type: Google tag.
- Tag ID: your measurement ID constant.
- Configuration setting: add
send_page_viewand set it tofalse. - Trigger: Initialization - All Pages.
Turning off the automatic page view stops GA4 counting each page twice. You send the page view yourself with its own event tag instead, which gives you control over what it carries. The longer video builds that tag as a GA4 event named page_view, with page_location, page_referrer and page_title as parameters, fired on the data layer's page view event.
Step 4: Create the variables and triggers
Variables. Create a Data Layer Variable for each field the data layer sends. The video has about 30 of them. The ones that matter most are:
ecommerce.value: the event's value, such as the order total.ecommerce.currency: the store's currency, such asUSD.ecommerce.items: the products array.ecommerce.transaction_id: the Shopify order ID.ecommerce.coupon, plus shipping and tax if you want them on the purchase.- The customer's email, phone, name and address, for user-provided data.
The video also uses a Google tag: Event Settings variable. It holds the parameters every event shares, such as the customer details, so you set them once and each event tag reads from it.
Triggers. Create a Custom Event trigger for each event name the data layer pushes: view_item, add_to_cart, begin_checkout, add_payment_info, purchase, and any others you want, such as view_cart, remove_from_cart, add_shipping_info and view_item_list. The longer video sets up 10 triggers this way. The trigger's event name must match the data layer exactly.
If you'd rather not build all of this by hand, the longer video shows importing a ready-made GTM template with the tags, triggers and variables already in it.
Step 5: Build the GA4 purchase tag
Start with the purchase. If it fires with full data, the rest will too.
In GTM, go to Tags → New and choose Google Analytics: GA4 Event.
- Measurement ID: your measurement ID constant.
- Event name:
purchase, all lower case. - Event Settings Variable: your shared event settings variable.
- Event parameters:
currency:ecommerce.currencyvalue:ecommerce.value, the real order total, never a fixed numbertransaction_id:ecommerce.transaction_iditems:ecommerce.itemscoupon, and in the longer video alsoshipping,taxandcustomer_type, if your data layer sends them
- User-provided data: the video points this to a User-Provided Data variable with the customer's email, phone, name and address.
- Trigger: your
purchasecustom event trigger.
The transaction_id matters more than it looks. GA4 drops a second purchase from the same user with the same transaction ID, so a reloaded thank-you page doesn't count twice. An empty transaction_id is worse than none: GA4 treats every purchase with an empty ID as one and the same (Analytics Help, minimize duplicate key events with transaction IDs). The Shopify order ID is unique per order, so it's the right value.
User-provided data only does anything if you switch it on in GA4: Admin → Data collection and modification → Data collection → User-provided data collection, and accept Google's policy there. Google can hash the values with SHA-256 for you before they're used.
Step 6: Copy it for the other ecommerce events
Every other event tag follows the same pattern: same tag type, same measurement ID, same event settings variable, same items mapping. Only the event name, the trigger and a few parameters change.
- view_item, add_to_cart, begin_checkout, add_payment_info:
currency,valueanditems, each with its own trigger. - add_shipping_info: the same three, plus
shipping_tierif your data layer sends it. - view_cart, remove_from_cart, view_item_list: optional, but they fill in the rest of the funnel.
The quickest way is to duplicate the purchase tag, rename it, change the event name and trigger, and remove the purchase-only parameters: transaction_id, coupon, shipping, tax and customer_type.
Step 7: Publish and test in DebugView
Click Submit, name the version, and Publish. Then check it with a real journey:
- In GA4, go to Admin → Data display → DebugView.
- In another tab, open GTM Preview with your store's address.
- View a product, add it to the cart, start checkout, fill in the contact details and complete a test order.
- Back in DebugView, you should see
view_item,add_to_cart,begin_checkout,add_shipping_infoandpurchasearrive in order.
Click the purchase event and open its parameters. You want the real currency, the real order total as value, the real order ID as transaction_id, and the full products in items. If one is missing or empty, the data layer isn't pushing it, or the variable name doesn't match. Go back to Step 4.
If DebugView stays empty, that's often the custom pixel sandbox, not your tags. Shopify says Tag Assistant's troubleshooting feature isn't compatible with custom pixels. The longer video uses the Google Analytics Debugger Chrome extension instead. Google also lets you turn on debug_mode in the Google tag to send everything to DebugView; remove the parameter when you're done, because setting it to false doesn't switch it off (Analytics Help, monitor events in DebugView).
Step 8: Check Realtime and the ecommerce reports
DebugView can be fussy, so check a second way. In GA4, open Reports → Realtime and scroll to Event count by Event name. Your ecommerce events should be there: view_item, add_to_cart, begin_checkout, add_shipping_info and purchase. In the longer video, purchase already shows as a key event. You can mark add_to_cart as a key event too, if it fits your goals.
The standard reports take longer. Open the Ecommerce purchases report (under Monetization, or Drive online sales in some properties) the next day. It shows the product names, revenue and item-level breakdown from your items arrays.
When the numbers come in, don't expect GA4 revenue to match Shopify to the cent. Consent, ad blockers, tax, shipping, refunds and time zones all move it. Why GA4 revenue differs from Shopify explains each reason and how to compare the two fairly.
Common mistakes
GA4 still connected through the Google & YouTube app. This is the big one. If the app sends GA4 events to the same property, every product view, add to cart and checkout reaches GA4 twice, once from the app and once from your GTM tags. Purchases are only dropped as duplicates when both copies carry the same transaction ID from the same user. Remove the GA4 connection from the app, and check your theme and other apps for a second GA4 or gtag.js snippet, before you publish. In DebugView, two copies of every event is the giveaway.
Event names in the wrong case. Purchase or AddToCart won't fill GA4's ecommerce reports. Use the recommended names, all lower case.
No items array. The purchase arrives with revenue, but the product reports stay empty. Map items on every ecommerce event, not only the purchase.
A value without a currency. Google needs currency whenever you send value, or revenue isn't calculated correctly.
The placeholder container ID left in the script. The pixel saves and connects, but nothing reaches GTM. Check the GTM- ID first if nothing fires.
Automatic page view left on. If the Google tag sends a page view and you also fire your own page_view tag, every page counts twice. Set send_page_view to false.
Judging the reports on day one. Realtime and DebugView show events in minutes. The ecommerce reports need about a day.
Questions people ask
Do I need the Google & YouTube app for GA4?
Not for this setup. GTM sends every GA4 event on its own. Some stores keep the app for Merchant Center and product feeds. If you do, make sure it isn't also sending GA4 events to the same property.
Why doesn't DebugView show my events?
Most often, debug mode isn't on for your browser. Custom pixels run in Shopify's sandbox, so GTM Preview can't always switch it on. Use the Google Analytics Debugger extension or debug_mode in the Google tag. Google also says events don't appear in DebugView when consent mode is active and you haven't accepted analytics cookies, so accept the banner on your test visit.
Which events should I track for Shopify ecommerce?
At least view_item, add_to_cart, begin_checkout, add_payment_info and purchase, each with currency, value and items. Add view_cart, remove_from_cart, add_shipping_info and view_item_list if you want the full funnel.
Why is GA4 revenue different from Shopify?
Shopify counts every order in its database. GA4 counts the purchase events that reach it. Consent, ad blockers, tax and shipping, refunds and test orders all open a gap. A small gap is normal; see Why GA4 revenue differs from Shopify.
Is this server-side tracking?
No. These tags run in the shopper's browser, inside Shopify's sandbox. Ad blockers and browser privacy settings can stop some events from reaching GA4. Server-side tracking sends them from your own server as well.
Where KiteTrack fits
KiteTrack sends your Shopify ecommerce events to GA4 from your own tracking server on your store's subdomain, with the items, value, currency and order ID on every purchase. It sends the same events to Meta, Google Ads and TikTok, hashes customer details before they're sent, and checks your tracking every 30 minutes, so a broken tag becomes an alert instead of a gap you find in next month's report. See how it works for GA4 server-side tracking on Shopify.
Not sure your GA4 is getting every sale? Start with the free Tracking Check. It looks at your site in about two minutes, no signup. If you'd rather talk it through, book a call with me.
Sources
- Google for Developers, GA4 recommended events reference: https://developers.google.com/analytics/devguides/collection/ga4/reference/events?client_type=gtm
- Google for Developers, Shopify event parameters (Google & YouTube app): https://developers.google.com/tag-platform/gtagjs/reference/shopify-event-parameters
- Analytics Help, Minimize duplicate key events with transaction IDs: https://support.google.com/analytics/answer/12313109?hl=en
- Analytics Help, Monitor events in DebugView: https://support.google.com/analytics/answer/7201382?hl=en
Get tracking tips by email
Short, practical fixes for Meta, Google Ads and GA4, from Abir.
You’re in. First tip lands soon.