TikTok6 min read1 view

Shopify TikTok View Content tracking with GTM

Send TikTok ViewContent from Shopify product pages with GTM. Check the selected variant, presentment currency and received event.

Watch on YouTube

Jump to the code

The short answer

Send TikTok ViewContent when a Shopify product page loads, using a Liquid data layer and a GTM event tag. TikTok lists ViewContent as a standard eventads.tiktok.com. This guide helps store implementers check the initially selected variant, item price and currency, then confirm the event in TikTok.

  • GTM trigger: custom_view_item.
  • TikTok event: ViewContent.
  • Use the selected variant price and matching cart currency.
  • 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 configuration; follow the current written steps below for the corrected event mapping and data fields.

How do I add GTM to the Shopify storefront?

Add the container to the development store's theme.liquid. Google's web-container instructionssupport.google.com place the script near the start of <head> and the noscript block immediately after <body>.

Use a development store and a GTM container reserved for testing. Check existing theme scripts and app pixels before adding another installation. This guide is for a Liquid storefront; use a separate implementation for a headless storefront.

1. Install or verify the test container

If that container is already installed, verify its location instead of inserting it again.

  1. Replace GTM-XXXX in both snippets below with the test container ID.
  2. In theme.liquid, paste the script near the start of <head>.
  3. Paste the noscript block immediately after <body>.
html
<!-- Google Tag Manager -->
  <script>(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');</script>
  <!-- End Google Tag Manager -->
html
<!-- Google Tag Manager (noscript) -->
  <noscript><iframe src="https://www.googletagmanager.com/ns.html?id=GTM-XXXX"
  height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
  <!-- End Google Tag Manager (noscript) -->

Done when the development theme contains the intended loader once.

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. 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.
  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 put Shopify product data in GTM?

Use the product.selected_or_first_available_variant propertyshopify.dev for the initial product view. This snippet sends one event on page load; it does not listen for later variant-selector changes.

3. Add the product data-layer snippets

  1. Create snippets/head-datalayer.liquid with the first block below.
  2. Create snippets/datalayer-product.liquid with the second block.
  3. Put the render line (the third block) inside theme.liquid after the GTM head loader.

If head-datalayer.liquid already exists, merge this page condition with its existing conditions. Keep one initialization and one render call in the theme.

liquid
<script>
  window.dataLayer = window.dataLayer || [];
</script>
 
{%- if template.name == 'product' -%}
  {%- render 'datalayer-product', product: product -%}
{%- endif -%}
liquid31 lines
{%- assign current_variant = product.selected_or_first_available_variant -%} {% if current_variant %}<script>console.log("datalayer-product snippet is loaded")var itemObject = {    item_id: {{ current_variant.id | append: "" | json }},    id: {{ current_variant.id | json }},    item_name: {{ product.title | json }},    currency: {{ cart.currency.iso_code | json }},    item_brand: {{ product.vendor | json }},    item_category: {{ product.type | json }},    item_variant: {{ current_variant.title | json }},    price: {{ current_variant.price }} / 100,    google_business_vertical: 'retail',    quantity: 1} 

13 more lines of Liquid

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

liquid
{% render 'head-datalayer' %}

Shopify outputs variant.price in the customer's presentment currencyshopify.dev; the snippet pairs it with cart.currencyshopify.dev and its iso_codeshopify.dev.

Done when custom_view_item contains the initial variant ID, numeric price and matching currency on a product page, and any earlier head-datalayer conditions remain with this page's own condition.

How do I send ViewContent to TikTok?

Use ViewContent, the event code in TikTok's standard event listads.tiktok.com.

Use custom_view_item as the GTM trigger and ViewContent 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.

  1. Create the variables in the table below, using Version 2 for nested paths.
  2. Create a Custom Event trigger whose event name is exactly custom_view_item, with regular-expression matching off.
  3. Create a Custom JavaScript variable named JS - TikTok contents with the mapping below the table.

DLV - Value

Data layer path
ecommerce.value
Expected value
Number, including zero

DLV - Currency

Data layer path
ecommerce.currency
Expected value
Currency code

DLV - Items

Data layer path
ecommerce.items
Expected value
Array of items
Create these variables in the same container as the event 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.

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, the JS - TikTok contents variable returns the expected items, and the ID convention is documented.

5. Add the TikTok event tag

This tag 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_view_item 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.
html
<script>
ttq.track('ViewContent', {
  contents: {{JS - TikTok contents}},
  value: {{DLV - Value}},
  currency: {{DLV - Currency}}
}, {
  pixel_code: {{Constant - TikTok pixel ID}}
});
</script>

Done when the saved event tag has the intended trigger, variables and base setup tag.

How do I test the Shopify ViewContent event?

Use GTM Previewsupport.google.com to inspect the data-layer event and tag, then check receipt in TikTok Test eventsads.tiktok.com. Save both observations; a successful tag firing is only one part of the check.

6. Test the event and its boundaries

  1. Load a product URL with a selected variant.
  2. Load another product.
  3. Follow the intended TikTok pixel's Test events flow and repeat the action.
  4. Repeat with each consent choice and compare the result with your consent plan.
  5. Switch the development storefront to a second supported presentment currency.
  6. Reload the selected product URL in GTM Preview.
  7. Repeat the TikTok Test events check.

Done when custom_view_item has the expected initial variant and the event tag fires once for that page load; the browser event is ViewContent, its parameters match the data layer and no unexplained duplicate appears; and in the second currency, the numeric variant price and event value match the displayed product price, both itemObject.currency and ecommerce.currency label that same currency, and the received ViewContent agrees.

When is this setup the wrong fix?

Use a separate interaction event if the job is to track every variant selection. This guide records the initial product page view.

  • Using shop.currency for a presentment price: the labels can disagree on a multi-currency store. Use the matching cart currency.
  • Using a collection visit as ViewContent for every product: this snippet belongs on product pages. Keep collection browsing separate.
  • Counting tag firing as receipt: compare the event with the intended TikTok pixel in Test events.

Continue with the next Shopify event guide once the event name and payload match your test action. Save the tested container, pixel ID and observations for production review.

What changed in this guide

  • 25 October 2026: Updated the Liquid page condition, variant ID and currency fields. Added explicit TikTok mapping and tests for the initial product view. Added a second-presentment-currency completion check. The video was not re-recorded.

Sources

15 sources
  1. 1TikTok lists ViewContent as a standard event↩
  2. 2Google's web-container instructions↩
  3. 3TikTok documents↩
  4. 4product.selected_or_first_available_variant property↩
  5. 5Shopify outputs variant.price in the customer's presentment currency↩
  6. 6cart.currency↩
  7. 7iso_code↩
  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. 14GTM Preview↩
  15. 15TikTok Test events↩