Shopify TikTok Purchase tracking with GTM
Track TikTok Purchase on Shopify with Customer events and GTM. Map the event payload, check values and test receipt in TikTok.
Shahzada Ali Hassan, founder of Crisperchecked against 18 sources
The short answer
Track TikTok purchases by sending Shopify's checkout completion event through GTM inside a custom pixel. TikTok now names the standard purchase event Purchaseads.tiktok.com. This guide is for store implementers replacing Additional Scripts and checking purchase values, zero-value orders and event receipt in TikTok.
- GTM trigger:
custom_purchase. - Shopify event:
checkout_completed. - TikTok event:
Purchase. - If an app already sends this event, check it before adding another sender.
- Steps and settings checked against Shopify and TikTok 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
The video shows the older Additional Scripts method; follow the current written steps below for Customer events.
Shopify has retired checkout.liquid and Additional Scripts on Thank you and Order status pagesshopify.dev. Do not paste the old Liquid purchase snippet into a custom pixel; use the subscription below.
01How do I load GTM in Shopify Customer events?
Copy the GTM head loader for your development store's test container. Shopify's GTM tutorialhelp.shopify.com says to remove the HTML script tags from the head loader before pasting it into the pixel editor.
Use a development store, a GTM container reserved for testing, and a TikTok pixel chosen for these tests. Check whether an app or existing script already sends this event before adding another sender.
Shopify calls custom pixels an advanced, unsupported featurehelp.shopify.com. This guide is for implementers who can maintain JavaScript; it is the wrong starting point if you need an app-managed installation.
1. Create the pixel and add the loader
- In Shopify, open Settings > Customer events.
- Add a custom pixel.
- Review its Customer privacy settingshelp.shopify.com and match them to the store's consent requirements.
- Paste the loader below into the pixel editor.
- Replace
GTM-XXXXwith your test container ID. - Add the event subscription from step 3 in the same editor.
// Use the GTM container reserved for your development store.
(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-XXXX');
Done when both pieces are in one pixel and the container ID is correct.
02How do I add the TikTok base pixel?
Use the base code from the intended pixel in TikTok Events Manager. TikTok documentsads.tiktok.com a Custom HTML base tag with an All Pages trigger.
2. Add the base code to the test container
- In GTM, create a Custom HTML tag named TikTok base.
- Paste that pixel's base code.
- Set its trigger to All Pages.
- Retain the store's consent controls on the tag.
- Create a Constant variable named Constant - TikTok pixel ID containing the same ID, for the event tag.
Done when the saved base code and variable contain the intended test pixel ID.
03How do I replace the Shopify purchase script?
Subscribe to checkout_completed and keep the existing custom_purchase data-layer name. The Shopify event referenceshopify.dev defines the payload used below; a subscription runs your function when Shopify emits that event.
3. Add the event subscription
The code keeps item data for GTM and reads the amount directly rather than replacing a missing amount with zero.
Shopify allows a line item's variant and its variant ID to be nullshopify.dev. The filter skips those entries before mapping, keeping the event's original value and currency.
- Append the JavaScript below after the loader.
- Test the subscription and GTM mapping locally with a synthetic
checkout_completedpayload containing valid event fields and a normal line. - Repeat with a synthetic payload whose line has
variant: null. - Repeat with a synthetic payload whose line has
variant.id: null. - Also test a checkout containing all three lines.
window.dataLayer = window.dataLayer || [];analytics.subscribe("checkout_completed", (event) => { const checkout = event.data.checkout; const amount = checkout.subtotalPrice?.amount; const currency = checkout.currencyCode; const orderId = checkout.order?.id; if (amount == null || !Number.isFinite(Number(amount)) || !currency || !orderId) { throw new Error("Purchase needs a subtotal and currency and an order ID"); } const items = checkout.lineItems .filter((item) => item.variant?.id) .map((item) => { const variant = item.variant; if (variant.price?.amount == null) { throw new Error("Purchase item needs a price"); } return { item_id: String(variant.id),
31 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 the saved code listens to checkout_completed and pushes custom_purchase in the same pixel as GTM. Every test run pushes custom_purchase and calls ttq.track with the original value and currency, and only the identified line appears in contents.
The value remains subtotal-based: Shopify defines subtotalPrice as the price before duties, shipping and taxesshopify.dev. Item prices are variant prices, so compare the subtotal separately when discounts apply. The order ID now comes from checkout.order.id, and item IDs use variant IDs rather than the old product IDs; check downstream mappings before changing senders. Shipping, tax, coupon and discount fields remain in the data layer for other tags. Customer lifetime fields from the legacy snippet are omitted because this example uses the checkout event payload.
When no items have IDs, the tag below omits contents.
04How do I send Purchase from GTM to TikTok?
Use Purchase for this new event tag. TikTok renamed CompletePayment to Purchase and still supports the old nameads.tiktok.com; do not send both names for the same order.
Use custom_purchase as the GTM trigger and Purchase as the name sent to TikTok. A trigger tells GTM when to run a tag; the data layerdevelopers.google.com holds the event and values that tag reads.
4. Create the variables and trigger
A Data Layer Variablesupport.google.com reads a named value for a tag. TikTok documents contents as an array of product objectsads.tiktok.com; its Pixel template sourceraw.githubusercontent.com uses content_id, content_type, content_name, price and quantity inside each object.
- Create each Data Layer Variable in the table below, using Version 2 for nested paths.
- Create a Custom Event trigger whose event name is exactly
custom_purchase. - Leave regular-expression matching off on that trigger.
- Create a Custom JavaScript variable named JS - TikTok contents with the mapping below.
DLV - Value
- Data layer path
- ecommerce.value
- Expected value
- Number, including zero
DLV - Currency
- Data layer path
- ecommerce.currency
- Expected value
- Currency code
DLV - Order ID
- Data layer path
- ecommerce.transaction_id
- Expected value
- Shopify order ID
DLV - Items
- Data layer path
- ecommerce.items
- Expected value
- Array of items
DLV - Event ID
- Data layer path
- event_id
- Expected value
- Shopify customer-event ID
function() { var items = {{DLV - Items}}; if (!Array.isArray(items)) { throw new Error('TikTok mapping needs an ecommerce.items array'); } return items.map(function(item) { return { content_id: String(item.item_id), content_type: 'product', content_name: item.item_name, price: Number(item.price),
4 more lines of JavaScript
- Copy and download
- Emailed to you
Unlock this snippet
One form opens every snippet on the blog
This example uses Shopify variant IDs and content_type: "product". For catalog use, compare an ID with your actual feed and adapt the mapping if needed: TikTok recommends matching the catalog SKU or item-group ID and pairing it with product or product_groupads.tiktok.com. Choose the matching ID and type together.
Done when each variable path and the trigger name match the table and the snippet, JS - TikTok contents returns the expected items, and the ID convention is documented.
5. Add the TikTok event tag
The code below uses the ttq.track(event, properties, options) call and pixel_code option in TikTok's official Pixel templateraw.githubusercontent.com; it keeps this guide's event name and value explicit.
- Create a Custom HTML tag with the code below.
- Attach only the
custom_purchasetrigger. - Use GTM tag sequencingsupport.google.com to run TikTok base before this event tag.
- Set the base tag to Once per pagesupport.google.com.
- Keep consent requirements on both tags.
<script>var contents = {{JS - TikTok contents}};var properties = { value: {{DLV - Value}}, currency: {{DLV - Currency}}, order_id: {{DLV - Order ID}}};if (contents.length) { properties.contents = contents;}ttq.track('Purchase', properties, {
4 more lines of HTML
- Copy and download
- Emailed to you
Unlock this snippet
One form opens every snippet on the blog
Done when the saved event tag has the intended trigger, variables and base setup tag.
05How do I test Shopify Purchase tracking?
Test the Shopify event first, then confirm the browser event in TikTok Events Manager > Test eventsads.tiktok.com. Shopify's helper checks the subscription; TikTok receipt is a separate check.
6. 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, then 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.
7. Connect the test pixel and exercise the event
- Save and connect the custom pixel on the development store.
- Select Test, following Shopify's Pixel Helper procedurehelp.shopify.com.
- Exercise the consent choices and check that the helper's consent state matches your choice.
- Complete a nonzero test order, using Shopify's test-order checklisthelp.shopify.com.
- Record its order ID, subtotal and currency.
- In Shopify Pixel Helper, check that
checkout_completedappears with a green dot and the expected payload. - Open the intended TikTok pixel's Test events flow.
- Repeat the action.
- For a zero-subtotal test, use a 100% discount code on eligible products in the development store.
- Check the final total before completing the order: Shopify's amount-off discounts do not apply to shipping costshelp.shopify.com.
- Complete the zero-subtotal order.
- Repeat the TikTok Test events check for that order.
- Keep the results with the test container version and pixel ID for production review.
Done when the pixel is Connected, the helper's consent state matches your choice, checkout_completed appears in Shopify Pixel Helper with a green dot and the expected payload, Purchase arrives in TikTok as a browser event whose currency and value agree with the Shopify payload with no unexplained duplicate, and TikTok receives numeric value: 0 for the zero-subtotal order.
Shopify says Tag Assistant's Troubleshoot tag feature is incompatible with custom pixelshelp.shopify.com. Use Shopify Pixel Helper and destination checks for this sandboxed setup.
06Which mistakes should I check first?
Start with the event source, then check the values and the tag that sent them.
- Keeping the old checkout script: it depends on the retired route. Replace it with Customer events.
- Sending both CompletePayment and Purchase: choose one sender for the same purchase.
- Replacing missing money with zero: distinguish an absent subtotal from a legitimate zero-value order.
07Why can a completed order be missing from this event?
Shopify says checkout_completed will not fire if its relevant page fails to loadshopify.dev. With post-purchase upsells, it fires on the first upsell page instead of repeating on the Thank you page. Compare the order with that event before changing the trigger.
08What should I check after the purchase event?
Continue with the next Shopify funnel-event guide after this event passes its checks. Keep the same pixel ID and document which setup sends each action.
09What changed in this guide
- 25 October 2026: Replaced retired Additional Scripts with Customer events. Updated the TikTok Purchase name, added explicit values and order IDs, and retained the zero-value discount test. Added null-ID checks that preserve event values and explicit test-container publication checks. The video was not re-recorded.
Sources
18 sources
- 1TikTok now names the standard purchase event Purchaseads.tiktok.com↩
- 2Shopify has retired checkout.liquid and Additional Scripts on Thank you and Order status pagesshopify.dev↩
- 3Shopify's GTM tutorialhelp.shopify.com↩
- 4Customer privacy settingshelp.shopify.com↩
- 5TikTok documentsads.tiktok.com↩
- 6Shopify event referenceshopify.dev↩
- 7TikTok renamed CompletePayment to Purchase and still supports the old nameads.tiktok.com↩
- 8data layerdevelopers.google.com↩
- 9Data Layer Variablesupport.google.com↩
- 10TikTok documents contents as an array of product objectsads.tiktok.com↩
- 11Pixel template sourceraw.githubusercontent.com↩
- 12GTM tag sequencingsupport.google.com↩
- 13Once per pagesupport.google.com↩
- 14TikTok Events Manager > Test eventsads.tiktok.com↩
- 15Google sayssupport.google.com↩
- 16Shopify's Pixel Helper procedurehelp.shopify.com↩
- 17Shopify's test-order checklisthelp.shopify.com↩
- 18Shopify's amount-off discounts do not apply to shipping costshelp.shopify.com↩


