Shopify product views for Google Ads remarketing
Track Shopify product views with Customer events and GTM. Send view_item to Google Ads using the variant price and a matching retail feed ID.
Shahzada Ali Hassan, founder of Crisperchecked against 15 sources
The short answer
Send Shopify product views to Google Ads by mapping product_viewed to a GTM view_item dynamic remarketing tag. Shopifyshopify.dev provides the viewed product variant, including its price and currency. This guide is for store owners and implementers maintaining a custom pixel.
- Listen for
product_viewedshopify.dev in Customer events. - The snippet pushes
view_itemto GTM. - Remarketing labels are optionalsupport.google.com; leave the label empty for this example.
- If an existing integration already covers this event, inspect it before adding another sender.
- Steps and settings checked against Shopify and Google 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
01Which variant should I check in the product-view event?
Inspect the variant in event.data.productVariant, the field in Shopify's product-view payloadshopify.dev, and match it to your test product. Change the variant selector in a separate test before assuming each change produces another event.
02How do I add the custom pixel in Shopify?
Prepare this walkthrough in a development store with a test GTM container. Shopify suggests testing pixels in a dev storehelp.shopify.com before adding them to a live store.
1. Open Customer events and check the loader
- In the test store, open Settings > Customer events > Add custom pixel.
- Name the pixel.
- Review its Customer privacy settings using Shopify's pixel instructionshelp.shopify.com, choosing settings that match your consent plan, and record them.
Shopify's GTM tutorialhelp.shopify.com uses the container loader as JavaScript without script tags. The snippet below includes a loader.
- Replace the snippet's GTM placeholder with the ID of a test container that only your development store loads.
- If this pixel already loads GTM, keep that loader once and append only the event subscription and its helper.
Done when the editor is open, the privacy settings are recorded and the pixel contains one loader for the intended test container.
03What code tracks Shopify product views?
Subscribe to product_viewed and push the mapped values into the data layerdevelopers.google.com, the object GTM reads for events. The Shopify event referenceshopify.dev documents the fields used below.
2. Add the event subscription
event.data.productVariant supplies id, price, product and sku, as listed in Shopify's payload referenceshopify.dev. The callback is the function that runs when Shopify delivers this event.
- Add the snippet below to the custom pixel in the test store.
- Save the pixel.
- Connect it following Shopify's connection stepshelp.shopify.com.
// 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; j.src = "https://www.googletagmanager.com/gtm.js?id=" + i + dl; f.parentNode.insertBefore(j, f);})(window, document, "script", "dataLayer", "GTM-EXAMPLE");function logEventToConsole(dataLayerEvent) { const customStyle01 = "color: #FFFF00; background-color: #000000; font-size: 10px; font-weight: bold; padding: 2px 0;"; console.log("%cDataLayer Event: view_item ", customStyle01, { event: dataLayerEvent.event, event_id: dataLayerEvent.event_data.id,
68 more lines of JavaScript
- 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 Customer events shows Connected and the saved code contains the product_viewed subscription once.
Shopify's event referenceshopify.dev allows product and variant IDs to be null. The filter keeps only rows whose product and variant IDs are strings with non-empty trim() results before mapping items. It preserves each retained ID unchanged. The event and its value stay intact even when no valid item remains.
Shopify supplies the viewed variant's priceshopify.dev, which this snippet uses as value. The snippet sets quantity to one as a viewing example; it is not a purchased quantity.
This revision keeps page details in page_data without changing browser history. history.pushState requires a same-origin URLdeveloper.mozilla.org; the event push no longer depends on that extra operation succeeding.
04How do I set up the Google Ads tag in GTM?
Use Google Ads Remarketing for this event. Google's tag instructionssupport.google.com describe the ID and label fields.
3. Create the variables and event trigger
A Data Layer Variable reads a named value for a tag. A trigger tells GTM when to run a tag.
- Create each Data Layer Variable in the table below using Version 2, which reads dots as nested fieldssupport.google.com.
- Create a Custom Event triggersupport.google.com with event name
view_item. - Leave regular-expression matching off.
DLV - Value
- Data layer variable name
- ecommerce.value
- Purpose
- Checkout or item amount
DLV - Currency
- Data layer variable name
- ecommerce.currency
- Purpose
- Currency from Shopify
DLV - Items
- Data layer variable name
- ecommerce.items
- Purpose
- Shopify items to map to feed IDs
Done when the saved variable names and paths match the table and the trigger's saved event name is view_item.
4. Map the tag fields
For retail, Google requires an item id matching the feed's id, item_group_id or display_ads_id, and recommends google_business_vertical: "retail"support.google.com. The snippet's item_id and product_id are Shopify identifiers; neither is automatically your feed ID.
- Create a Custom JavaScript variable named
JS - Ads itemswith this mapping. - Replace the placeholder entries using the exact Shopify variant IDs and feed IDs from your test products, so each tested variant has a non-empty entry that matches the feed.
function () { var items = {{DLV - Items}}; // Replace these placeholders with verified IDs from your store and feed. // Add an entry for every variant included in this test. var feedIdsByVariant = { "REPLACE_SHOPIFY_VARIANT_ID": "REPLACE_MERCHANT_CENTER_ID" }; if (!Array.isArray(items)) { throw new Error("Dynamic remarketing needs an item array"); } // No identifiable products: keep the data-layer event, but do not fire the tag. if (items.length === 0) return []; return items.map(function (item) { var variantId = String(item.product_id); if (!Object.prototype.hasOwnProperty.call(feedIdsByVariant, variantId)) { throw new Error("Missing verified feed ID for variant " + variantId); } var feedId = feedIdsByVariant[variantId];
9 more lines of JavaScript
- Copy and download
- Emailed to you
Unlock this snippet
One form opens every snippet on the blog
Missing or empty feed IDs raise an error; correct the mapping before testing the tag. An empty source array returns an empty mapping for the trigger to exclude. The next variable counts the validated feed items returned by JS - Ads items.
- Create another Custom JavaScript variable named
JS - Ads item countwith the code below. - On the event trigger, choose Some Custom Events.
- Add
JS - Ads item countgreater than0, using GTM trigger filterssupport.google.com. - Keep the exact event name.
- Attach this filtered trigger to the remarketing tag, with no additional unfiltered trigger.
function () {
var items = {{JS - Ads items}};
return Array.isArray(items) ? items.length : 0;
}
Google's GTM example uses Event Name, Event Value and Event Itemssupport.google.com; the mappings below adapt that example to this snippet.
- In the remarketing tag, enable Send dynamic remarketing event data.
- Fill the fields in the table below.
- Check the associated Google tag is present in the test container; Google's remarketing instructions require it for optimal browser compatibilitysupport.google.com.
- Save the event tag.
Conversion ID
- Setting
- Your Google Ads audience-source Conversion ID
Conversion Label
- Setting
- Leave empty for this example
Event Name
- Setting
- view_item
Event Value
- Setting
- {{DLV - Value}}
Event Items
- Setting
- {{JS - Ads items}}
Trigger
- Setting
- view_item; JS - Ads item count greater than 0
The Google tag IDsupport.google.com is distinct from your GTM- container ID.
Done when each tested variant has a non-empty mapping entry that matches the feed, the saved trigger contains the item-count condition, the tag has no additional unfiltered trigger, and the tag's fields, destination and trigger match your test plan.
05How do I test product views on Shopify?
Use Customer events > Test to inspect the event with Shopify Pixel Helperhelp.shopify.com, then inspect the Google request separately. Start with the test store and test container prepared above.
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.
- Open the test container that only your development store loads.
- Select Submit, then choose Publish and Create Version.
- 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 one test action through the setup
- Open the connected custom pixel and choose Test using Shopify's testing stepshelp.shopify.com.
- Exercise the consent choice for your test and check that Pixel Helper's consent status matches that choice.
- Open a known product details page and inspect the variant supplied by Shopify: Pixel Helper should list
product_viewedwith the variant ID, price and currency in that product-view event. - Inspect the pixel's console entry and data-layer push for
view_item: the event name should match your saved GTM trigger and the expected fields should contain the test values. - Inspect the outgoing Google Ads remarketing request in browser developer tools: its destination,
view_itemevent and retail item IDs should match your test product feed, and its value should match the tested item amount. - Record the test time, event ID, container version and observed request fields, noting what passed and any missing or repeated request that still needs investigation.
Then check the ID handling locally.
- Run the subscription locally with null, empty, whitespace-only and non-string values for each ID field.
- Test a valid item separately.
- Combine the retained arrays from valid and invalid cases for a mixed-list formatter check.
- Repeat with amounts of 0 and a nonzero amount, passing retained items through any downstream formatter.
- Resolve
DLV - Items,JS - Ads itemsandJS - Ads item countby name in that order.
Done when every browser check above matches and your notes identify anything still to investigate; locally, the event, currency and value stay intact, genuine IDs remain unchanged, no mapped ID is blank or replaced by a product name, the count matches the mapped feed items, an empty mapping gives 0 and excludes the tag, and missing or blank feed IDs raise an error.
06When is this the wrong setup, and what can go wrong?
Use this guide when you need to maintain this custom event mapping. Shopify advises reviewing available apps before creating a custom pixelhelp.shopify.com; if an app already handles the job, inspect that integration first.
- Using an unmatched Shopify product ID: Google requires the retail ID to match a supported feed fieldsupport.google.com. Map the exact feed ID before testing.
- Adding a second sender without checking the first: Shopify warns overlapping pixel installations can count events twicehelp.shopify.com. Inventory the existing event sender before adding this one.
- Saving a tag without checking the actual request: a filled-out tag is only a configuration. Match the request fields to your recorded test action.
If you also need storefront coverage, the Shopify Google Ads page-view guide walks through the separate page-view trigger.
07What changed in this guide
- 25 October 2026: Added the Shopify event explanation, Google Ads tag mappings and test checks; preserved existing event names and corrected payload handling. Added explicit Merchant Center feed-ID mapping for retail remarketing. Removed the history update before the event push. Added the isolated test-container publication procedure and published-version check. Filtered items missing either product or variant IDs and added null-item checks without changing event values. Added an empty-items trigger condition and validation for blank feed IDs. Replaced the repeated introduction with the next event-specific check. Rejected whitespace-only and non-string item IDs while preserving genuine IDs, and added formatter checks for mixed and invalid items. Corrected the Ads items input to DLV - Items while retaining the mapped-item count and greater-than-zero trigger.
Sources
15 sources
- 1product_viewedshopify.dev↩
- 2Remarketing labels are optionalsupport.google.com↩
- 3Shopify suggests testing pixels in a dev storehelp.shopify.com↩
- 4Shopify's pixel instructionshelp.shopify.com↩
- 5Shopify runs custom pixels in a sandboxhelp.shopify.com↩
- 6Shopify's GTM tutorialhelp.shopify.com↩
- 7data layerdevelopers.google.com↩
- 8history.pushState requires a same-origin URLdeveloper.mozilla.org↩
- 9Version 2, which reads dots as nested fieldssupport.google.com↩
- 10Custom Event triggersupport.google.com↩
- 11Google requires an item id matching the feed's id, item_group_id or display_ads_id, and recommends google_business_vertical: "retail"support.google.com↩
- 12GTM trigger filterssupport.google.com↩
- 13Google's GTM example uses Event Name, Event Value and Event Itemssupport.google.com↩
- 14Google tag IDsupport.google.com↩
- 15Google sayssupport.google.com↩

