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.
Shahzada Ali Hassan, founder of Crisperchecked against 15 sources
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.
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 configuration; follow the current written steps below for the corrected event mapping and data fields.
01How 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.
- Replace
GTM-XXXXin both snippets below with the test container ID. - In
theme.liquid, paste the script near the start of<head>. - Paste the noscript block immediately after
<body>.
<!-- 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 -->
<!-- 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.
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
- 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.
- 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 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
- Create
snippets/head-datalayer.liquidwith the first block below. - Create
snippets/datalayer-product.liquidwith the second block. - Put the render line (the third block) inside
theme.liquidafter 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.
<script>
window.dataLayer = window.dataLayer || [];
</script>
{%- if template.name == 'product' -%}
{%- render 'datalayer-product', product: product -%}
{%- endif -%}
{%- 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.
{% 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.
04How 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.
- Create the variables in the table below, using Version 2 for nested paths.
- Create a Custom Event trigger whose event name is exactly
custom_view_item, with regular-expression matching off. - 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
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.
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.
- Create a Custom HTML tag with the code below.
- Attach only the
custom_view_itemtrigger. - 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>
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.
05How 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
- Load a product URL with a selected variant.
- Load another product.
- Follow the intended TikTok pixel's Test events flow and repeat the action.
- Repeat with each consent choice and compare the result with your consent plan.
- Switch the development storefront to a second supported presentment currency.
- Reload the selected product URL in GTM Preview.
- 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.
06When 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.
07What 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
- 1TikTok lists ViewContent as a standard eventads.tiktok.com↩
- 2Google's web-container instructionssupport.google.com↩
- 3TikTok documentsads.tiktok.com↩
- 4product.selected_or_first_available_variant propertyshopify.dev↩
- 5Shopify outputs variant.price in the customer's presentment currencyshopify.dev↩
- 6cart.currencyshopify.dev↩
- 7iso_codeshopify.dev↩
- 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↩
- 14GTM Previewsupport.google.com↩
- 15TikTok Test eventsads.tiktok.com↩


