Shopify Facebook Pixel ViewCategory with GTM
Track Shopify collection views with a custom Meta ViewCategory event. Preserve the Liquid data layer and test product-list mapping in GTM.
Shahzada Ali Hassan, founder of Crisperchecked against 15 sources
Tools
The short answer
Track Shopify collection views by pushing custom_view_item_list from the collection template and sending a custom Meta ViewCategory event. The preserved Liquid snippet includes the collection title and its products. This guide is for implementers maintaining a theme-based collection event and checking which product list reaches the intended pixel.
- GTM trigger:
custom_view_item_list; Meta custom event:ViewCategory. - The payload uses product IDs and the collection title.
- If you need checkout events, use Customer events separately.
- Steps and settings checked against linked documentation and tutorial files on 25 October 2026.
FREE AUDIT
NO LOGINCheck what Meta and Google can count on your site
- Your site
Crisper- Meta and Google count it
Enter your website to see how good its tracking is, and whether Meta is likely restricting it.
On this page 12 sections
- How do I track Shopify collection views in Meta?
- How do I load GTM on Shopify collections?
- How do I check the base Facebook Pixel?
- How do I add the collection data-layer helper?
- What code sends the collection products?
- Where do I render the collection helper?
- How do I check the collection data before creating a tag?
- How do I create the Meta ViewCategory tag?
- How do I test Shopify ViewCategory?
- When is this collection setup the wrong fix?
- What should I check after a collection view?
- What changed in this guide
01How do I track Shopify collection views in Meta?
Use the collection data layer below and a custom ViewCategory tag. Shopify's collection objectshopify.dev provides the title and product list used by the preserved snippet. Work in a development store with a test GTM container.
02How do I load GTM on Shopify collections?
Load the test container in the theme that renders your collection pages.
1. Install the container in a test theme
Reuse an existing theme installation if it is already correct.
- Use a development store and a duplicate theme.
- From the test GTM container, copy both snippets.
- Place the script high in the head, following Google's installation placementsupport.google.com.
- Place the noscript block after the opening body tag.
Done when GTM Preview connects to the intended container on the test storefront.
03How do I check the base Facebook Pixel?
Keep the base PageView tag separate from the ViewCategory tag. The Shopify PageView guide covers the base event.
2. Check the storefront base pixel
- Create a tag from the Meta Pixel templategithub.com with your pixel ID.
- Choose standard event PageView.
- Fire it on All Pages, subject to the store's consent controls.
- Save the tag.
Keep this separate from the product or collection tag.
Done when the base tag is saved against the intended pixel and PageView appears in your test session.
04How do I add the collection data-layer helper?
Create a head-datalayer helper that initializes the array and renders the collection snippet on the matching template.
3. Create head-datalayer.liquid
- Save the first block as the head-datalayer snippet in the test theme.
- If this helper already exists, merge the collection condition into it instead of overwriting its other event code.
<script>
window.dataLayer = window.dataLayer || [];
</script>
{%- if template == 'collection' -%}
{%- render 'datalayer-collection', collection: collection -%}
{%- endif -%}
Done when the helper file exists and names datalayer-collection in its render call.
05What code sends the collection products?
The collection snippet pushes custom_view_item_list with a list name and an items array. Each entry uses the product ID, plus details of its selected or first available variant.
Shopify defines variant.priceshopify.dev in the customer's presentment currency, meaning the currency shown to that visitor. shop.currencyshopify.dev is the store currency, which can differ. cart.currencyshopify.dev matches the customer's presentment currency on multi-currency stores and the store currency otherwise. Use its iso_codeshopify.dev to label the rendered prices.
4. Create datalayer-collection.liquid
- Save the following block as the datalayer-collection snippet.
<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 -%} {
17 more lines of Liquid
- Copy and download
- Emailed to you
Unlock this snippet
Three details, and the full code is yours
No account needed. Unlock once and every snippet on the blog opens.
Done when the file is saved with the custom_view_item_list event name and collection fields intact.
06Where do I render the collection helper?
Render head-datalayer once from the test theme, after its GTM loader.
5. Add the theme render statement
- Insert the statement below into theme.liquid in your test theme.
{% render 'head-datalayer' %}
Done when the collection visit creates custom_view_item_list in Preview.
07How do I check the collection data before creating a tag?
Inspect the event payload on the collection page before mapping it to Meta. The exact template condition in the helper and the product loop define this snippet's scope.
Check. Compare the rendered list
- Open the collection page in GTM Preview.
- Check ecommerce.item_list_name and ecommerce.items against the collection you visited.
- Also test any alternate collection template or pagination your store uses.
- Record any unsupported template behavior before proceeding.
- Switch the development storefront to a second presentment currency.
- Reload the same collection in GTM Preview.
- Compare the selected or first available variants with their displayed prices.
- Record both currency runs.
Done when the list name and item IDs describe the intended rendered collection, any unsupported template behavior is recorded, and in the second currency every ecommerce.items entry pairs its rendered variant price with that currency's ISO code, rather than the store currency.
08How do I create the Meta ViewCategory tag?
Create a Custom Event trigger for custom_view_item_list and a Meta Pixel templateraw.githubusercontent.com tag with Custom > ViewCategory. A trigger tells GTM which event should run the tag.
The original Facebook Parameter Generator repository is archivedgithub.com. To retain this tutorial's mapping, import its template into the test container, following Google's template import instructionsdevelopers.google.com.
- Download its template.tplraw.githubusercontent.com.
- In the test container, go to Templates > Variable Templates > New.
- Use More actions > Import.
- Select the file and save.
Done when Facebook Parameter Generator appears as a variable template with the documented array and key fields.
6. Map the product fields
A variable reads a named field for the tag.
- Create Version 2 Data Layer Variablessupport.google.com for
ecommerce.itemsand the other paths in the table. - Use the Facebook Parameter Generatorraw.githubusercontent.com with the items variable, ID key
item_id, name keyitem_name, price keypriceand quantity keyquantity. - Create its contents, IDs and name outputs.
- In the ViewCategory tag, add the properties below.
- Enter your pixel ID.
- Leave automatic ecommerce mapping off.
- Attach only the custom_view_item_list trigger and save the tag.
contents
- Value to map
- Generator contents output
content_ids
- Value to map
- Generator IDs output
content_name
- Value to map
- Generator name output
content_type
- Value to map
- Literal product
content_category
- Value to map
- ecommerce.item_list_name
Done when the saved tag reads the intended fields and uses only the custom_view_item_list trigger.
The collection payload has currency inside each item, not a top-level ecommerce.currency field. This mapping sends collection and product information without inventing a collection revenue value. The quantity 1 in each item describes the listed product, not a purchase.
09How do I test Shopify ViewCategory?
Test the storefront in GTM Previewsupport.google.com, then compare the destination event in Meta Events Manager.
7. Follow the event from the theme to Meta
- Open a collection.
- Open a product from that collection.
- Select
custom_view_item_listin Preview. - Inspect the variables and confirm the event tag fires there.
- In the intended pixel's Test Events, find
ViewCategoryfrom that visit. - Confirm ViewCategory belongs to the collection visit and is not sent by the product visit.
- Record the consent state.
- Repeat with the other consent choice.
Done when the source fields and Meta event match, and any additional firing is explained.
10When is this collection setup the wrong fix?
Use it for theme-rendered collection lists. For checkout events, use Customer events because Shopify has retired the old checkout script locationsshopify.dev.
- Choosing standard ViewContent: it labels a different action. Use Custom > ViewCategory for this collection event.
- Treating list value as revenue: listed merchandise is not a sale. Keep revenue reporting attached to completed purchases.
- Assuming every theme variation works: the helper has an explicit template condition. Check the actual collection template in Preview.
11What should I check after a collection view?
Use the Shopify ViewContent guide for the next product-page visit. Note that this collection snippet uses product IDs while that product snippet uses variant IDs; reconcile the two before catalog matching.
12What changed in this guide
- 25 October 2026: Documented the archived generator import path. Clarified the custom ViewCategory setting, collection payload scope and product-versus-variant IDs. Removed unsupported top-level currency/value assumptions from collection mapping and added test completion checks. Corrected copied product instructions to datalayer-collection and custom_view_item_list, and removed the unsourced event-delay claim. Corrected item currency to cart.currency.iso_code and added a second-presentment-currency check.
Sources
15 sources
- 1Shopify's collection objectshopify.dev↩
- 2Shopify warns about overlapping pixel installationshelp.shopify.com↩
- 3Google's installation placementsupport.google.com↩
- 4Meta Pixel templategithub.com↩
- 5variant.priceshopify.dev↩
- 6shop.currencyshopify.dev↩
- 7cart.currencyshopify.dev↩
- 8iso_codeshopify.dev↩
- 9Meta Pixel templateraw.githubusercontent.com↩
- 10Facebook Parameter Generator repository is archivedgithub.com↩
- 11Google's template import instructionsdevelopers.google.com↩
- 12template.tplraw.githubusercontent.com↩
- 13Data Layer Variablessupport.google.com↩
- 14GTM Previewsupport.google.com↩
- 15Shopify has retired the old checkout script locationsshopify.dev↩

