Shopify Google Ads purchase tracking with GTM
Track Shopify purchases in Google Ads with Customer events and GTM. Map order value, currency and transaction ID, then verify a test order.
Shahzada Ali Hassan, founder of Crisperchecked against 14 sources
The short answer
Track Shopify purchases through Customer events, then map the order amount, currency and transaction ID into a Google Ads conversion tag. Shopifyshopify.dev documents checkout_completed as firing once per checkout, sometimes on an upsell page. This guide is for store owners and implementers maintaining a custom pixel.
- Listen for
checkout_completedshopify.dev in Customer events. - The snippet pushes
purchaseto GTM. - Conversion tags need an ID and labelsupport.google.com.
- If an existing integration already covers this event, inspect it before adding another sender.
- Steps and settings checked against Shopify and Google documentation on 25 October 2026.
FREE CALL
30 MINMeta stopped counting your leads? Get them counted again.
- Pick a time
Check your Meta account with Hassan- See what to do next
On a free 30-minute call, Hassan checks your Meta account with you and shows you what to do next.
Not ready to talk? Run a free check
01What should I check before adding the Purchase tag?
Inventory app-based Purchase senders, imported conversions and custom tags before adding the test tag. Record each destination and trigger; Shopify warns that overlapping pixel installations can count events twicehelp.shopify.com.
02How do I add the custom pixel in Shopify?
Prepare this walkthrough in a development store with a test GTM container. Shopify suggests testing pixels in a dev storehelp.shopify.com before adding them to a live store.
1. Open Customer events and check the loader
- In the test store, open Settings > Customer events > Add custom pixel.
- Name the pixel.
- Review its Customer privacy settings using Shopify's pixel instructionshelp.shopify.com, and use settings that match your consent plan.
Shopify's GTM tutorialhelp.shopify.com uses the container loader as JavaScript without script tags. The snippet below includes a loader.
- Replace the snippet's GTM placeholder with the ID of a test container that only your development store loads.
- If this pixel already loads GTM, keep that loader once and append only the event subscription and its helper.
Done when the editor is open, the privacy settings are recorded and the pixel contains one loader for the intended test container.
03What code tracks Shopify purchases?
Subscribe to checkout_completed and push the mapped values into the data layerdevelopers.google.com, the object GTM reads for events. The Shopify event referenceshopify.dev documents the fields used below.
2. Add the event subscription
event.data.checkout supplies order.id, totalPrice.amount, currencyCode, totalTax, shippingLine and lineItems, as listed in Shopify's payload referenceshopify.dev. The callback is the function that runs when Shopify delivers this event.
- Add the snippet below to the pixel's code.
- Save and connect the pixel in the test store following Shopify's connection stepshelp.shopify.com.
// Initialize the dataLayerwindow.dataLayer = window.dataLayer || [];(function (w, d, s, l, i) { w[l] = w[l] || []; w[l].push({ "gtm.start": new Date().getTime(), event: "gtm.js" }); var f = d.getElementsByTagName(s)[0], j = d.createElement(s), dl = l != "dataLayer" ? "&l=" + l : ""; j.async = true; j.src = "https://www.googletagmanager.com/gtm.js?id=" + i + dl; f.parentNode.insertBefore(j, f);})(window, document, "script", "dataLayer", "GTM-EXAMPLE");function logEventToConsole(dataLayerEvent) { const customStyle01 = "color: #FFFF00; background-color: #000000; font-size: 10px; font-weight: bold; padding: 2px 0;"; console.log("%cDataLayer Event: purchase ", customStyle01, { event: dataLayerEvent.event, event_id: dataLayerEvent.event_data.id,
94 more lines of JavaScript
- Copy and download
- Emailed to you
Unlock this snippet
Two details, and the full code is yours
No account needed. Unlock once and every snippet on the blog opens.
Done when Customer events shows Connected and the saved code contains the checkout_completed subscription once.
Shopify's event referenceshopify.dev allows product and variant IDs to be null, and checkout line items can have a null variant. The filter keeps only rows whose product and variant IDs are strings with non-empty trim() results before mapping items. It preserves each retained ID unchanged. The event and its value stay intact even when no valid item remains.
Use checkout.order.id as the transaction ID, not event.id. Shopify defines the event ID as the customer-event ID and the order as the paid-checkout resultshopify.dev.
The address mapping reads shippingAddress.province, the region field in Shopify's referenceshopify.dev. The retained user_data object is not mapped into the basic Google Ads tag below; keep enhanced-conversion work separate.
Shopify defines a discount code as the title of a DISCOUNT_CODE applicationshopify.dev. The snippet filters that type before joining its titles, so an automatic discount name is not presented as a code.
This revision keeps page details in page_data without changing browser history. history.pushState requires a same-origin URLdeveloper.mozilla.org; the event push no longer depends on that extra operation succeeding.
04How do I set up the Google Ads tag in GTM?
Use Google Ads Conversion Tracking for this purchase. Google's tag instructionssupport.google.com describe the ID and label fields.
3. Create the variables and event trigger
A Data Layer Variable reads a named value for a tag, and a trigger tells GTM when to run a tag.
- Create each Data Layer Variable in the table below, using Version 2, which reads dots as nested fieldssupport.google.com.
- Create a Custom Event triggersupport.google.com with event name
purchase. - Turn regular-expression matching off on that trigger.
DLV - Value
- Data layer variable name
- ecommerce.value
- Purpose
- Checkout or item amount
DLV - Currency
- Data layer variable name
- ecommerce.currency
- Purpose
- Currency from Shopify
DLV - Order ID
- Data layer variable name
- ecommerce.transaction_id
- Purpose
- Order identifier
Done when the saved variable names and paths match the table and the trigger's saved event name is purchase.
4. Map the tag fields
- In Google Ads, open the intended conversion action.
- Select Tag setup > Use Google Tag Manager.
- Copy its Conversion ID and Conversion Label into the GTM tag; Google distinguishes the account ID from the action-specific labelsupport.google.com.
- Set the remaining tag fields and trigger as shown in the table below.
- Check the associated Google tag is present in the test container; Google's remarketing instructions require it for optimal browser compatibilitysupport.google.com. The Google tag IDsupport.google.com is distinct from your
GTM-container ID. - Save the event tag.
Conversion ID
- Setting for this walkthrough
- Your test action's account Conversion ID
Conversion Label
- Setting for this walkthrough
- The label for your purchase action
Conversion Value
- Setting for this walkthrough
- {{DLV - Value}}
Currency Code
- Setting for this walkthrough
- {{DLV - Currency}}
Transaction ID
- Setting for this walkthrough
- {{DLV - Order ID}}
Trigger
- Setting for this walkthrough
- purchase
Done when the saved tag's fields, destination and trigger match your test plan.
This example keeps totalPrice.amount as the conversion value. Shopify defines totalPrice as the total including duties, taxes and discountsshopify.dev; compare it with the test checkout total rather than an item-price sum.
Google detects a duplicate when the same conversion action receives the same transaction IDsupport.google.com. Keep the order ID stable for retries, and never reuse one static ID for different orders.
05How do I test purchases on Shopify?
Use Customer events > Test to inspect the event with Shopify Pixel Helperhelp.shopify.com, then inspect the Google request separately. Start with the test store and test container prepared above.
5. Publish the version in the test container
Changes saved in a workspace do not run yet. Google sayssupport.google.com you need to publish workspace changes to make them operational.
- Open the test container that only your development store loads.
- Select Submit.
- Choose Publish and Create Version.
- Name the version and publish.
Do not publish to a container your live store loads; move the tested setup there through your normal release process.
Done when the test container's Versions list shows your version as published and the pixel code loads that container's ID.
6. Follow one test action through the setup
- Open the connected custom pixel and choose Test using Shopify's testing stepshelp.shopify.com.
- Exercise the consent choice for your test, and check that Pixel Helper's consent status matches that choice.
- Complete a test order.
- Record its order ID, currency and checkout total.
- In Pixel Helper, check that
checkout_completedis listed and that its order ID, value and currency match the same test order. - Inspect the pixel's console entry and data-layer push for
purchase: the event name should match your saved GTM trigger and the expected fields should contain the test values. - In browser developer tools, inspect the outgoing Google Ads conversion request: the intended ID and label, numeric total, currency and transaction ID should match the test order, with no unexplained second purchase request.
- Record the test time, event ID, container version and observed request fields.
- Run the subscription locally with null, empty, whitespace-only and non-string values for each ID field.
- Include a null-variant checkout line, a mixed list with a valid line, and an all-invalid list.
- Repeat with amounts of 0 and a nonzero amount, passing retained items through any downstream formatter. The event, currency, transaction ID and value should stay intact, genuine IDs should remain unchanged, and no mapped ID should be blank or replaced by a product name.
Done when every check above matches and your notes identify what passed and any missing or repeated request that still needs investigation.
06When is this the wrong setup, and what can go wrong?
Use this guide when you need to maintain this custom event mapping. Shopify advises reviewing available apps before creating a custom pixelhelp.shopify.com; if an app already handles the job, inspect that integration first.
- Hardcoding one transaction ID for every purchase: Google warns this can undercount conversionssupport.google.com. Pass the order-specific ID.
- Adding a second sender without checking the first: Shopify warns overlapping pixel installations can count events twicehelp.shopify.com. Inventory the existing event sender before adding this one.
- Saving a tag without checking the actual request: a filled-out tag is only a configuration. Match the request fields to your recorded test action.
07Why can Shopify purchase events be missing?
Check the completion page and any upsell flow before changing the trigger.
Does checkout_completed always fire on the Thank you page?
No. Shopify says upsell and post-purchase flows emit it on the first upsell offer page insteadshopify.dev. It is not emitted again on the Thank you page, so inspect that earlier event.
What if the completion page never loads?
Shopify says the event is not emitted if its relevant page fails to loadshopify.dev. Compare store orders with received conversions separately when investigating missing purchases.
If you also need storefront coverage, the Shopify Google Ads page-view guide walks through the separate page-view trigger.
08What changed in this guide
- 25 October 2026: Added the Shopify event explanation, Google Ads tag mappings and test checks; preserved existing event names and corrected payload handling. Corrected the address region lookup and discount-code mapping. Removed the history update before the event push. Added the isolated test-container publication procedure and published-version check. Filtered items missing either product or variant IDs and added null-item checks without changing event values. Replaced the repeated introduction with the next event-specific check. Rejected whitespace-only and non-string item IDs while preserving genuine IDs, and added formatter checks for mixed and invalid items.
Sources
14 sources
- 1checkout_completedshopify.dev↩
- 2Conversion tags need an ID and labelsupport.google.com↩
- 3Shopify warns that overlapping pixel installations can count events twicehelp.shopify.com↩
- 4Shopify suggests testing pixels in a dev storehelp.shopify.com↩
- 5Shopify runs custom pixels in a sandboxhelp.shopify.com↩
- 6Shopify's GTM tutorialhelp.shopify.com↩
- 7data layerdevelopers.google.com↩
- 8history.pushState requires a same-origin URLdeveloper.mozilla.org↩
- 9Version 2, which reads dots as nested fieldssupport.google.com↩
- 10Custom Event triggersupport.google.com↩
- 11Google's remarketing instructions require it for optimal browser compatibilitysupport.google.com↩
- 12Google tag IDsupport.google.com↩
- 13Google detects a duplicate when the same conversion action receives the same transaction IDsupport.google.com↩
- 14Google sayssupport.google.com↩

