TikTok8 min read3 views

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.

Watch on YouTube

Jump to the code

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.

Ask an assistant

ChatGPTClaudePerplexity

FREE CALL

30 MIN

Meta stopped counting your leads? Get them counted again.

  1. Pick a time
  2. Check your Meta account with Hassan
  3. 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.

Book my free recovery callFree 30-minute call with Hassan.

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.

How 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

  1. In Shopify, open Settings > Customer events.
  2. Add a custom pixel.
  3. Review its Customer privacy settingshelp.shopify.com and match them to the store's consent requirements.
  4. Paste the loader below into the pixel editor.
  5. Replace GTM-XXXX with your test container ID.
  6. Add the event subscription from step 3 in the same editor.
javascript
// 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.

How 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

  1. In GTM, create a Custom HTML tag named TikTok base.
  2. Paste that pixel's base code.
  3. Set its trigger to All Pages.
  4. Retain the store's consent controls on the tag.
  5. 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.

How 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.

  1. Append the JavaScript below after the loader.
  2. Test the subscription and GTM mapping locally with a synthetic checkout_completed payload containing valid event fields and a normal line.
  3. Repeat with a synthetic payload whose line has variant: null.
  4. Repeat with a synthetic payload whose line has variant.id: null.
  5. Also test a checkout containing all three lines.
javascript49 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.

We email you a copy.

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.

How 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.

  1. Create each Data Layer Variable in the table below, using Version 2 for nested paths.
  2. Create a Custom Event trigger whose event name is exactly custom_purchase.
  3. Leave regular-expression matching off on that trigger.
  4. 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
Create these variables in the same container as the event tag.
javascript15 lines
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.

  1. Create a Custom HTML tag with the code below.
  2. Attach only the custom_purchase trigger.
  3. Use GTM tag sequencingsupport.google.com to run TikTok base before this event tag.
  4. Set the base tag to Once per pagesupport.google.com.
  5. Keep consent requirements on both tags.
html15 lines
<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.

How 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.

  1. Open the test container that only your development store loads.
  2. Select Submit, then choose Publish and Create Version.
  3. 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

  1. Save and connect the custom pixel on the development store.
  2. Select Test, following Shopify's Pixel Helper procedurehelp.shopify.com.
  3. Exercise the consent choices and check that the helper's consent state matches your choice.
  4. Complete a nonzero test order, using Shopify's test-order checklisthelp.shopify.com.
  5. Record its order ID, subtotal and currency.
  6. In Shopify Pixel Helper, check that checkout_completed appears with a green dot and the expected payload.
  7. Open the intended TikTok pixel's Test events flow.
  8. Repeat the action.
  9. For a zero-subtotal test, use a 100% discount code on eligible products in the development store.
  10. Check the final total before completing the order: Shopify's amount-off discounts do not apply to shipping costshelp.shopify.com.
  11. Complete the zero-subtotal order.
  12. Repeat the TikTok Test events check for that order.
  13. 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.

Which 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.

Why 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.

What 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.

What 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
  1. 1TikTok now names the standard purchase event Purchase↩
  2. 2Shopify has retired checkout.liquid and Additional Scripts on Thank you and Order status pages↩
  3. 3Shopify's GTM tutorial↩
  4. 4Customer privacy settings↩
  5. 5TikTok documents↩
  6. 6Shopify event reference↩
  7. 7TikTok renamed CompletePayment to Purchase and still supports the old name↩
  8. 8data layer↩
  9. 9Data Layer Variable↩
  10. 10TikTok documents contents as an array of product objects↩
  11. 11Pixel template source↩
  12. 12GTM tag sequencing↩
  13. 13Once per page↩
  14. 14TikTok Events Manager > Test events↩
  15. 15Google says↩
  16. 16Shopify's Pixel Helper procedure↩
  17. 17Shopify's test-order checklist↩
  18. 18Shopify's amount-off discounts do not apply to shipping costs↩