Shopify9 min read1 view

Shopify View Category tracking with Facebook Pixel and GTM

Track Shopify collection views as a custom Meta ViewCategory event. Map collection titles and product variants without treating list prices as sales.

Watch on YouTube

The short answer

Track Shopify View Category through Customer events and GTM by mapping collection_viewed to Meta's ViewCategory event. Shopify documentsshopify.dev the collection title and product variants in data.collection. This guide helps store owners and implementers maintain a custom pixel and check the data it sends.

  • GTM listens for view_item_list; Meta receives ViewCategory.
  • Use Custom for ViewCategory in the Meta templateraw.githubusercontent.com.
  • If an existing sender already covers this event, inspect it before adding another.
  • Steps and settings checked against Shopify documentation and Meta's template on 25 October 2026.

Ask an assistant

ChatGPTClaudePerplexity

FREE AUDIT

NO LOGIN

Check what Meta and Google can count on your site

  1. Your site
  2. Crisper
  3. Meta and Google count it

Enter your website to see how good its tracking is, and whether Meta is likely restricting it.

Run a free audit

How do I track Shopify View Category with GTM?

Use collection_viewed to send the custom Meta event ViewCategory. The GTM trigger remains view_item_list, while the Meta name describes the category visit.

The collection-view referenceshopify.dev describes a product collection page. A collection visit is different from opening a product detail page, so keep ViewCategory separate from ViewContent.

The accompanying video uses an earlier version of this Customer events walkthrough; use the written steps below for the revised code, privacy choices and testing sequence.

Use this setup when you need a custom event mapping and can maintain its JavaScript. If the store already uses Facebook and Instagram by Metahelp.shopify.com, inspect its events first; Shopify warns that overlapping installations can produce duplicate or incorrect reports.

Work in a development store with a GTM web container reserved for testing and a test Meta pixel. Have access to Customer events, the container and Meta Events Manager. Shopify describes custom pixels as an advanced, unsupported featurehelp.shopify.com; use an app integration if you need a maintained installation.

How do I add a custom pixel in Shopify?

Create or reuse a custom pixel in Settings > Customer events. Keep this event subscription with the GTM loader that will receive it.

1. Name the pixel and review Customer privacy

  1. Select Add custom pixel.
  2. Name the pixel for this setup and select Add pixel.
  3. Review Permission and Data sale using Shopify's privacy settingshelp.shopify.com rather than copying a blanket permission choice.

Done when the editor is open and the saved settings match the store's consent plan.

What code sends View Category to the data layer?

The collection payloadshopify.dev contains id, title and productVariants. The retained snippet sums listed variant prices into ecommerce.value; that is a list-price sum, not a cart total, so this tag does not send it as value.

The data layer is the queue of named events and values GTM reads, as described in Google's guidedevelopers.google.com. Shopify passes event datashopify.dev, called a payload, to the function inside analytics.subscribe. This example keeps the original view_item_list event name and nested payload paths.

2. Add the loader and subscription

  1. Paste the JavaScript below into the test pixel. It includes the loader, following Shopify's GTM custom-pixel patternhelp.shopify.com; do not add a second loader if your existing pixel already has one.
  2. Replace GTM-EXAMPLE with the ID of a test container that only your development store loads.
  3. Save and connect the pixel.
view_item_list.js85 lines
// Initialize the dataLayerwindow.dataLayer = window.dataLayer || [];(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;

76 more lines of JavaScript

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

We email you a copy. We may follow up on WhatsApp.

Done when Customer events shows Connected and the saved code contains the intended ID and one collection_viewed subscription.

The code keeps zero amounts instead of replacing them with empty text. It no longer calls history.pushState: Meta's template documents automatic PageViews from history changesraw.githubusercontent.com, so an ecommerce action should not manufacture a page navigation.

Which GTM variables does ViewCategory need?

Create variables for the values your tag will send. A Data Layer Variablesupport.google.com reads a named path from the data layer; a Constant stores a fixed value such as the test pixel ID. A trigger tells GTM when to run a tag.

3. Create the variables and exact event trigger

  1. In GTM, create a Constant variable named Meta Pixel ID with your test pixel ID.
  2. Create each Data Layer Variable in the table below, using Version 2 for nested paths.
  3. Add a Custom Event trigger whose event name is exactly view_item_list, with regular-expression matching off, and save it.

Meta Pixel ID

Value or data layer path
Constant: your test pixel ID
Use in this setup
Pixel ID

DLV - Event ID

Value or data layer path
event_data.id
Use in this setup
Event ID

DLV - Collection name

Value or data layer path
ecommerce.item_list_name
Use in this setup
Object property content_name

DLV - Items

Value or data layer path
ecommerce.items
Use in this setup
Input for the optional item formatter
Use these exact paths with the snippet above; variable display names can be chosen to fit your workspace.

Done when the saved variables match the table and the trigger listens for view_item_list.

Keep item details available with the existing formatter

  1. Import the Ecommerce Parameter Generator under Templates > Variable Templates.
  2. Create a variable from it named EPG - Contents.
  3. Set Array of Objects to DLV - Items.
  4. Under What to return, choose contents [ {} ] and save.

Done when the saved variable uses the items array and the contents output.

DownloadLocked
Ecommerce-Parameter-Generator.tpl
  • Download the file
  • Emailed to you

Unlock this file

One form opens every snippet on the blog

The downloadable formatter builds item details from item_id, item_name, price and quantity. Use its contents output rather than loading its complete Meta object, which includes a calculated monetary value.

How do I configure the Meta ViewCategory tag?

Use the Meta Pixel template from Meta's official GTM repositorygithub.com. Select Custom and enter ViewCategory, following the template's event-name controlsraw.githubusercontent.com.

ViewCategory is a custom name in this guide, not one of the template's standard event namesraw.githubusercontent.com. Preserve its spelling when comparing reports or configuring rules that use it.

4. Map the properties and save the tag

  1. Create a tag from the Meta Pixel template, select Custom and enter ViewCategory.
  2. Enter Meta Pixel ID as the pixel ID.
  3. Set Event ID to DLV - Event ID, and leave automatic ecommerce mapping off for this example.
  4. Under Object Properties, set content_name = DLV - Collection name.
  5. Clear the template's Opt in to a Meta-enabled Conversions API integration boxraw.githubusercontent.com. It is ticked by default, and while it is ticked the tag opts the pixel in to that integration. This guide sets up the browser tag only, so clear it on this tag and on any other Meta Pixel tag that uses the same pixel.
  6. Attach only the view_item_list trigger and save.

Done when reopening the tag shows ViewCategory, the test pixel ID, the specified fields, the exact trigger and the opt-in box cleared.

If you need item details, add contents = EPG - Contents and content_type = product in Object Properties. Done when the saved tag contains both properties and the received test event shows the intended item IDs. Compare those IDs with your actual catalog before using this mapping for catalog matching.

Shopify's collection_viewed referenceshopify.dev allows Product.id and ProductVariant.id to be null. This snippet uses the product ID for item_id, so it skips entries without a non-blank product ID. It keeps the collection name when every item is skipped; the ViewCategory tag still sends no monetary value. The formatter falls back to item_name when item_id is empty; filtering first prevents a product title becoming a catalog ID.

  1. Test a local payload with a normal product ID: ecommerce.items[].item_id and the formatter's contents[].id should retain that exact ID.
  2. Repeat with product.id: null and a real product title: ecommerce.items and the formatter's contents should be empty, the collection name should remain and the tag should have no value property.
  3. Test a mixed list with valid and null product IDs in the same payload: only the valid IDs should reach contents, each event should retain its collection name, and no contents.id should be a product title.

Done when all three local payloads give the results described above.

The Event ID fieldraw.githubusercontent.com can support browser/server deduplication, which counts matching copies as one event. This walkthrough configures a browser sender only. If you also send events from a server, use the same ID for the same action.

How do I test Shopify View Category tracking?

Follow the event through Shopify Pixel Helper and then Meta Events Manager. A green dot in Shopify Pixel Helperhelp.shopify.com means the subscription code ran successfully; verify Meta receipt and parameter values separately.

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

6. Follow a test action through both systems

  1. Open the connected pixel and select Test, following Shopify's testing procedurehelp.shopify.com.
  2. Exercise the store's consent flow and check that Pixel Helper's consent status matches your choice.
  3. Open a collection containing known products.
  4. In Pixel Helper, expand collection_viewed and compare its collection title and supplied variants with the viewed collection.
  5. Repeat with an empty collection if the store has one.
  6. In the browser console, check that the logged view_item_list object's event name and mapped values agree with the Shopify payload, with no unexplained errors.
  7. In Meta Events Manager Test Events, inspect ViewCategory on the intended test pixel: its time and properties should match your action, its received URL should be appropriate, and there should be no unexplained second send.
  8. Save the tested container version, pixel ID, action time, observed fields and any failures.

Done when every comparison above matches and your notes distinguish the Shopify subscription check from the Meta receipt check.

Shopify says Tag Assistant's Troubleshoot tag feature is incompatible with custom pixelshelp.shopify.com. If the test container cannot load the saved tag version, stop and resolve the test environment with its owner; changing a live container is not a debugging step.

Why is my ViewCategory event missing or duplicated?

Check the event source, tag mapping and test environment before adding another sender.

  • Reporting a sum of collection prices as sales value: no purchase happened. Send the collection name and optional item details without a monetary value.
  • Copying the loader or subscription twice: the same action can be processed twice. Keep one loader per custom pixel and one subscription for this mapping.
  • Assuming every collection contains products: an empty list has no first item or currency. Test an empty collection and send its name without a monetary value.

What should I check after ViewCategory?

Test the next part of the journey with the Shopify view content guide and Shopify add to cart guide. Record the source event, mapped fields and Meta receipt for each stage.

What changed in this guide

  • 25 October 2026: Checked the collection_viewed payload against Shopify's reference, corrected the data mapping and Meta event settings, and replaced blanket privacy and live-publish instructions with development-store checks. Added the test-container publish step and the Conversions API opt-in setting. Skipped items without a non-blank product ID before formatting contents, and added normal-ID, null-ID and mixed-list checks. Preserved the collection name without sending a monetary value.

Sources

11 sources
  1. 1Meta template↩
  2. 2Shopify documents↩
  3. 3Facebook and Instagram by Meta↩
  4. 4Shopify describes custom pixels as an advanced, unsupported feature↩
  5. 5Google's guide↩
  6. 6Shopify's GTM custom-pixel pattern↩
  7. 7Shopify pixels run in a sandbox↩
  8. 8Data Layer Variable↩
  9. 9Meta's official GTM repository↩
  10. 10green dot in Shopify Pixel Helper↩
  11. 11Google says↩