You will send a GA4 add_to_wishlist event every time a shopper saves a product on your Shopify store. The setup has two parts: your theme publishes a custom event with Shopify.analytics.publish, and a custom pixel in Settings > Customer events listens for it with analytics.subscribe and passes it to Google's tag. The Web Pixels API pages on shopify.dev show no version number, so the code below follows the docs and help center samples as they read in November 2026.

How it works

A wishlist add reaches GA4 through three moving parts, and each one lives in a different place.

  1. The theme publishes the event. When the wishlist button saves a product, theme JavaScript calls Shopify.analytics.publish('my_store:wishlist_added', data). Shopify's Emitting Data docs say custom events can be published from theme Liquid files and theme app extensions, and that every custom pixel and app pixel can then access them.
  2. The custom pixel subscribes. Custom pixels run in a lax sandbox, an iframe that can't reach the top frame of the page. Inside it, analytics, browser and init are ready to use without any register boilerplate, according to the Web Pixels API overview.
  3. The pixel calls GA4. Your pixel loads Google's gtag.js and sends the recommended add_to_wishlist event, with the product data that arrived in event.customData.

The reason for the detour is the sandbox. Shopify's pixels overview lists what sandboxed pixels can't detect on their own, including events and metadata from DOM scraping. A pixel can't watch for a click on your heart icon, so the theme has to announce the save.

Before you start

You need access to the theme code, a GA4 measurement ID, and permission to manage Customer events in the Shopify admin. Plan your consent setup before you write any code.

  • Theme access: you will add a data attribute block and a small script to the snippet that renders your wishlist button.
  • GA4 measurement ID: the ID that goes into gtag('config', ...).
  • Consent: by default, new custom pixels require Marketing and Analytics permissions and qualify as data sale. In markets configured to require consent, such as the EEA and the UK, the pixel runs only after visitors grant those permissions. To ask for consent, the store needs a cookie banner.
  • No duplicate tags: Shopify's guide to managing custom pixels tells you to remove or change existing pixel code in theme.liquid and in checkout's additional scripts first, so events aren't counted twice.

If you use an app for the wishlist itself, check what it already sends. Themivo Wishlist & Alerts, for example, sends wishlist adds to GA4, Meta, TikTok or Google Tag Manager through Shopify custom pixels, so you can skip the publishing code below. It is free, with every feature included.

Disclosure: we make this app.

The help center pages on custom pixels that we read don't list a plan requirement. Shopify does call custom pixels an advanced, unsupported feature that requires JavaScript, and suggests hiring a Shopify Partner if you need help.

Step 1: Give the wishlist button its product data

The theme should hand the product's details to the event at the moment of the save, so put them on the button as data attributes. These Liquid properties come from Shopify's product, variant and currency references.

{%- assign v = product.selected_or_first_available_variant -%}
<button type="button" class="wishlist-button"
  data-product-id="{{ product.id }}"
  data-variant-id="{{ v.id }}"
  data-sku="{{ v.sku | escape }}"
  data-title="{{ product.title | escape }}"
  data-price="{{ v.price }}"
  data-currency="{{ cart.currency.iso_code }}">
  Save to wishlist
</button>

Note that variant.price is in the currency's subunit (cents for USD), so the script divides it by 100 before GA4 sees it. If your theme changes the selected variant without a page load, update data-variant-id and data-price in the same code that updates the price on the page.

Step 2: Publish a custom event when the save succeeds

Publish the event after your wishlist code confirms the save, not on every click, so a failed save never reaches GA4. Shopify's docs recommend a prefix such as my_app:event_name to avoid collisions with standard events, and partners and merchants can't publish standard events at all.

document.addEventListener('click', async (e) => {
  const btn = e.target.closest('.wishlist-button');
  if (!btn) return;
  const saved = await saveToWishlist(btn); // your existing save logic
  if (!saved) return;
  const d = btn.dataset;
  Shopify.analytics.publish('my_store:wishlist_added', {
    product_id: d.productId,
    variant_id: d.variantId,
    sku: d.sku,
    title: d.title,
    price: Number(d.price) / 100,
    currency: d.currency,
  });
});

saveToWishlist stands in for whatever your theme or app already runs. Place the script in a theme app extension or in a script tag in theme.liquid, which are the two online store locations the Emitting Data page names.

Step 3: Create the custom pixel and load gtag.js

Create the pixel in Settings > Customer events: enter a unique name, click Add pixel, paste your code into the Code window, then click Save and Connect pixel. The sandbox runs only JavaScript, so Google's script src= tag has to become a script element created in code. This is the help center's own custom pixel sample for Google Analytics:

const script = document.createElement('script');
script.setAttribute('src', 'https://www.googletagmanager.com/gtag/js?id=G-XXXXXXX');
script.setAttribute('async', '');
document.head.appendChild(script);

window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'G-XXXXXXX');

Replace G-XXXXXXX with your measurement ID in both places. Shopify warns that Google's SDK doesn't send any Shopify data on its own: every event you want in GA4 needs its own subscription.

Step 4: Subscribe and send addtowishlist

The pixel subscribes to your custom event by name and reads the payload from event.customData. Google's GA4 event reference describes add_to_wishlist as the event for an item added to a wishlist. It takes currency, value and an items array, and each item needs item_id or item_name.

analytics.subscribe('my_store:wishlist_added', (event) => {
  const d = event.customData || {};
  const price = Number(d.price);
  if (!d.variant_id || !Number.isFinite(price)) return;

  gtag('event', 'add_to_wishlist', {
    currency: d.currency,
    value: price,
    items: [{
      item_id: d.sku || d.variant_id,
      item_name: d.title,
      price: price,
      quantity: 1,
    }],
  });
});

The guard clause matters. Shopify's docs caution that custom events can be published by users, other developers and even visitors from their browser console, so check the payload before you forward it. Google says value should be the sum of price times quantity, and that currency is required when you set value for revenue metrics to be computed accurately.

If you run Google Tag Manager instead

Push the event to the data layer and let a GTM tag send it to GA4. Shopify's GTM custom pixel tutorial loads the GTM container in the pixel, then pushes each subscribed event:

analytics.subscribe('my_store:wishlist_added', (event) => {
  window.dataLayer.push({
    event: 'wishlist_added',
    item_id: event.customData?.variant_id,
    item_name: event.customData?.title,
    value: event.customData?.price,
    currency: event.customData?.currency,
  });
});

In GTM, create a custom event trigger whose Event name is wishlist_added (the tutorial says it must match the event key in your pixel), add a data layer variable for each value, and fire a GA4 event tag named add_to_wishlist. At least one tag and one trigger must exist before any data moves.

Leave Permission set to Required for the purposes your region needs, and map them to Google's consent settings. The help center's mapping of Marketing and Analytics to Google Consent Mode is a single call you can place after gtag('config', ...):

gtag('consent', 'update', {
  'ad_storage': 'granted',
  'analytics_storage': 'granted',
  'ad_user_data': 'granted',
  'ad_personalization': 'granted',
});

Shopify notes that these example settings might not match your region's privacy rules, so check them with your own counsel. Then test, following Shopify's testing guide:

  1. In Settings > Customer events, open the pixel and click Test to open it on your online store.
  2. If the Pixel Helper shows Pixel is awaiting consent, accept tracking in the cookie banner or click Give consent to continue test.
  3. Save a product to the wishlist and look for my_store:wishlist_added under Events received.
  4. A green dot means the callback ran; a red dot means it failed, and expanding the event shows the error.

While you debug, a temporary analytics.subscribe('all_custom_events', ...) that logs event.customData to the console shows exactly what the theme sent.

Limits and gotchas

Most problems with this setup come from the sandbox, consent and duplicate code rather than from GA4 itself.

  • No DOM access: the lax sandbox is an iframe without access to the top frame, so window.location inside the pixel returns the sandbox URL. Read page details from the event's context instead, for example event.context.document.location.href.
  • Sandbox URLs in GA4: Shopify's GTM tutorial suggests turning off GA4's automatic page tracking and sending your own page view from the page_viewed event, so page URLs don't carry sandbox information.
  • Enhanced measurement: events GA4 normally infers, such as outbound link clicks, aren't triggered automatically inside a custom pixel. Publish them as custom events if you need them.
  • Standard events can't carry extra data: Shopify doesn't support adding custom data to standard events, which is another reason the wishlist needs its own custom event.
  • Customer account pages: pixels load there only after you connect a custom subdomain for customer accounts, and they track only page_viewed. Saves made from a wishlist page inside customer accounts won't arrive as custom events.
  • Consent gaps: visitors in consent regions who decline tracking never reach GA4, and pixels marked as data sale don't run for visitors who opted out. Third-party consent tools must sync with Shopify's Customer Privacy API, or the pixel may not fire even after consent.
  • Testing tools: the Pixel Helper tests one custom pixel at a time, clears its log on every page load, and doesn't work on headless stores or stores in private mode. Google Tag Assistant's Troubleshoot tag feature can't see tags inside a custom pixel.
  • Page speed: every pixel is another script. Shopify warns that more scripts slow a store down, so keep one GA4 pixel rather than several.

Frequently asked questions

Does GA4 have a built-in wishlist event?

Yes. GA4's recommended events include add_to_wishlist, which Google describes as the event for an item added to a wishlist. It accepts currency, value and an items array, and each item needs either item_id or item_name.

Can a Shopify custom pixel detect clicks on a wishlist button?

No. Custom pixels run in a sandboxed iframe that can't read or watch your page's DOM, so they can't detect button clicks on their own. Your theme has to publish a custom event with Shopify.analytics.publish, and the pixel subscribes to it with analytics.subscribe.

Why do wishlist events stop for some visitors?

In markets that require consent, such as the EEA and the UK, a custom pixel runs only after the visitor grants the permissions set in the pixel. New custom pixels require Marketing and Analytics permissions by default, and pixels marked as data sale don't run for visitors who opted out of data sales.

Should the wishlist event use the variant ID or the SKU?

Use the identifier your GA4 product reports and your ad feeds already use, and keep it the same across events. GA4 only requires one of item_id or item_name. The code above sends the SKU when there is one and falls back to the variant ID.

Do I need this code if my wishlist app already sends events?

Not always. Some wishlist apps already send wishlist adds through Shopify custom pixels. Themivo Wishlist & Alerts sends them to GA4, Meta, TikTok or Google Tag Manager, so you'd skip the theme publishing step. Check what your app sends before adding a second event, or GA4 will count each save twice.

Next steps

Once wishlist adds show up in GA4, mark add_to_wishlist as a key event if it matters to your reporting, and compare saved items with purchases to see which products people want but don't buy yet. If you're still choosing the wishlist itself, our comparison of the best wishlist apps for Shopify covers the options.

Official docs used in this guide:

To skip the theme code entirely, install Themivo Wishlist & Alerts from the Shopify App Store and send wishlist adds to GA4 through Shopify custom pixels without writing code.