Shopify TikTok collection tracking with GTM
Track Shopify collection views as a TikTok custom event with GTM. Keep collection browsing separate from purchases and product views.
Shahzada Ali Hassan, founder of Crisperchecked against 16 sources
The short answer
Track a Shopify collection-page visit with a custom TikTok ViewCategory event sent through GTM. TikTok custom events are separate from its predefined standard eventsads.tiktok.com. This guide is for store implementers measuring collection browsing, preserving the existing data-layer trigger and checking that a collection visit never becomes a purchase.
- GTM trigger:
custom_view_item_list. ViewCategoryis a custom event, notPurchase.- This snippet records the collection page, not each product impression.
- 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 track a Shopify collection-page visit?
Render a collection data layer on collection pages only, using Shopify's template.nameshopify.dev to identify the page type. Keep custom_view_item_list as the GTM trigger.
3. Add the collection-page condition
- Create
snippets/head-datalayer.liquid. - Paste the condition below.
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 == 'collection' -%}
{%- render 'datalayer-collection', collection: collection -%}
{%- endif -%}
Done when the snippet calls datalayer-collection only for the collection template, and any earlier conditions remain with this page's own condition.
04Which collection data should I send to GTM?
Keep the collection name and product list in GTM. Shopify's collection referenceshopify.dev provides title and products; this is a page-load list, not a measurement of which products a visitor actually saw.
4. Save the collection data snippet
- Create
snippets/datalayer-collection.liquid. - Paste the code below and save.
<script> console.log("datalayer-collection snippet is loaded") dataLayer.push({ ecommerce: null }); dataLayer.push({ event: "custom_view_item_list", ecommerce: { item_list_name: {{ collection.title | json }}, items: [{%- for product in collection.products -%} { item_id: {{ product.id | json }}, id: {{ product.id | json }}, item_name: {{ product.title | json }}, currency: {{ cart.currency.iso_code | json }}, index: {{ forloop.index | json }}, item_brand: {{ product.vendor | json }}, item_category: {{ product.type | json }}, item_list_name: {{ collection.title | json }}, item_variant: {{ product.selected_or_first_available_variant.title | json }},
8 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.
Done when the saved snippet pushes custom_view_item_list with the collection name and its Liquid product list.
Each listed price comes from product.selected_or_first_available_variantshopify.dev and variant.priceshopify.dev; pair it with the cart's presentment currencyshopify.dev. The TikTok tag below sends only the collection name, leaving these item details available for other GTM tags.
05Where do I render the collection data-layer snippet?
- Open
theme.liquid. - Paste the render line below once, after the GTM head loader.
- Save the theme.
{% render 'head-datalayer' %}
Done when the saved theme has this render line once.
06How do I check the collection data before sending it?
- Open a collection page in GTM Preview.
- Select
custom_view_item_list.
Done when the data layer shows the correct collection title; a product page should not create this collection event.
07How do I send ViewCategory to TikTok?
Send a custom event named ViewCategory, not Purchase. ViewCategory is absent from TikTok's standard event listads.tiktok.com; TikTok's custom-event guideads.tiktok.com describes custom events as reporting and audience signals rather than direct optimization events.
5. Create the collection variable and trigger
A Data Layer Variablesupport.google.com reads a named value from the data layer. A Custom Event trigger tells GTM to run the tag when the matching event name is pushed.
- Create a Version 2 Data Layer Variable named DLV - Collection name for
ecommerce.item_list_name. - Create a Constant variable named Constant - TikTok pixel ID for the intended pixel.
- Set a Custom Event trigger to exactly
custom_view_item_list.
Done when Preview resolves the collection-name variable on that event.
6. Create the collection event tag
The code below follows the ttq.track call shape in TikTok's official Pixel templateraw.githubusercontent.com. TikTok documents content_name as a string for the page or product nameads.tiktok.com; here it holds the collection title.
- Create a Custom HTML tag using the code below.
- Attach only the
custom_view_item_listtrigger. - Use GTM tag sequencingsupport.google.com to run TikTok base first.
- Set the base tag to Once per pagesupport.google.com.
<script>
ttq.track('ViewCategory', {
content_name: {{DLV - Collection name}}
}, {
pixel_code: {{Constant - TikTok pixel ID}}
});
</script>
Done when the saved tag sends ViewCategory and contains no Purchase call or purchase trigger.
08How do I test the Shopify ViewCategory 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.
7. Test the event and its boundaries
A purchase is not needed for this collection test. Keep the 100% discount code exercise for a separate zero-value order test in the TikTok Purchase guide; it does not verify ViewCategory.
- Open two different collection pages.
- Then open a product page.
- 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 a collection in GTM Preview.
- Check the
custom_view_item_listitem prices and theircart.currency.iso_codelabels in the data layer; thisViewCategorytag sends only the collection name.
Done when custom_view_item_list carries each collection name and does not fire on the product page; the browser event is ViewCategory, its parameters match the data layer and no unexplained duplicate appears; and in the second currency, the item prices and their cart.currency.iso_code labels agree with the displayed storefront prices.
09When is this setup the wrong fix?
This setup is for collection-page visits. It is not a purchase signal or a product-impression tracker.
- Copying the old Purchase tag: collection browsing would be labelled as a purchase. Use the ViewCategory tag above.
- Sending collection products as purchased items: a page listing does not establish a purchase. Keep the TikTok payload to the collection name.
- Expecting filtering or infinite scroll to emit new events: this code has no listener for those actions. Add a separate measured interaction only if you need it.
10What should I check after collection tracking?
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.
11What changed in this guide
- 25 October 2026: Corrected collection visits to custom ViewCategory events. Replaced copied Purchase instructions with collection tests and updated Liquid currency fields. Added a second-presentment-currency completion check. The video was not re-recorded.
Sources
16 sources
- 1TikTok custom events are separate from its predefined standard eventsads.tiktok.com↩
- 2Google's web-container instructionssupport.google.com↩
- 3TikTok documentsads.tiktok.com↩
- 4Shopify's template.nameshopify.dev↩
- 5Shopify's collection referenceshopify.dev↩
- 6product.selected_or_first_available_variantshopify.dev↩
- 7variant.priceshopify.dev↩
- 8cart's presentment currencyshopify.dev↩
- 9TikTok's standard event listads.tiktok.com↩
- 10Data Layer Variablesupport.google.com↩
- 11TikTok's official Pixel templateraw.githubusercontent.com↩
- 12TikTok documents content_name as a string for the page or product nameads.tiktok.com↩
- 13GTM tag sequencingsupport.google.com↩
- 14Once per pagesupport.google.com↩
- 15GTM Previewsupport.google.com↩
- 16TikTok Test eventsads.tiktok.com↩


