> ## Documentation Index
> Fetch the complete documentation index at: https://swish.app/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Meta Pixel

> Send every save to your Meta Pixel as an AddToWishlist event, for audiences and retargeting.

Swish fires Meta's standard `AddToWishlist` event when a customer who allows marketing saves a product, so saves count in your Meta Pixel alongside views, add-to-carts and purchases. It is on by default, and when your pixel is loaded in the theme there is nothing to set up.

## What Swish sends

One `AddToWishlist` per save, whether the customer saved from a save button, the size picker or the cart:

```js theme={null}
fbq(
  "track",
  "AddToWishlist",
  {
    content_ids: ["51565037781329"], // the saved variant's Shopify ID
    content_type: "product",
    value: 29.95, // the variant's price, in currency units
    currency: "AUD",
  },
  { eventID: "wl_<item id>" },
);
```

`value` and `currency` are the saved variant's Storefront API price in the customer's market. `eventID` is stable per saved item, so a later server-side send through the Conversions API can deduplicate against it.

## How it reaches your pixel

How your Meta Pixel is installed decides whether there is anything to do.

### Pixel loaded in the theme

If your theme loads the Meta Pixel base code, so that `fbq` is a global on the page, Swish calls `fbq` directly. Nothing to set up.

Swish first asks Shopify's [Customer Privacy API](https://shopify.dev/docs/api/customer-privacy) whether the customer allows marketing, and sends nothing when they don't. Where your cookie banner asks for consent, that means a save from a customer who declined or has not answered yet does not reach the pixel. Where no consent is required, every save does.

### Facebook & Instagram app, or a custom pixel

Shopify's Facebook & Instagram app installs the pixel inside Shopify's sandboxed customer events, where Swish cannot reach it, and the app does not forward events from other apps. When there is no `fbq` on the page, Swish instead publishes a `swish-add-to-wishlist` customer event with the same payload. A custom pixel forwards it to Meta:

1. In your Shopify admin, go to **Settings** > **Customer events** and click **Add custom pixel**.
2. Paste your Meta Pixel base code without its `fbq("track", "PageView")` line, then subscribe to the event:

```js theme={null}
fbq("init", "<PIXEL_ID>");

analytics.subscribe("swish-add-to-wishlist", (event) => {
  const { eventId, ...payload } = event.customData;
  fbq("track", "AddToWishlist", payload, { eventID: eventId });
});
```

If you already run a custom pixel for Meta, add the `analytics.subscribe` block to it rather than creating a second pixel.

### Tracking tools

Elevar, Stape, Littledata and similar tools can subscribe to `swish-add-to-wishlist` the same way and map it to Meta's `AddToWishlist`, which keeps the event inside their deduplication and Conversions API setup.

> [!NOTE]
>
> With the pixel loaded in the theme, Swish calls `fbq` and does not publish the
> customer event, so a store never gets two browser events for one save. An
> event sent from a custom pixel does not pass through the Facebook & Instagram
> app's Conversions API.

## Catalog content IDs

`content_ids` carries the saved variant's Shopify ID. Dynamic retargeting matches it against the **Content ID** of the items in your Meta catalog, so check that your catalog uses variant IDs: in Commerce Manager, open your catalog, pick any item and look at its Content ID. If your catalog keys on product IDs or SKUs instead, contact [support@swish.app](mailto:support@swish.app).

## Remove your own listener

If you added a theme script that listens to `item-create` and calls `fbq` yourself, remove it. Otherwise every save is counted twice.

## Turn it off

Set `integrations.metaPixel.enabled` to `false` in [`window.SwishOptions`](https://swish.app/docs/references/sdk/configuration#integrations) before the Swish app embed runs:

```js theme={null}
window.SwishOptions = {
  ...window.SwishOptions,
  integrations: { metaPixel: { enabled: false } },
};
```

`window.SwishOptions` overrides your setup one top-level key at a time: a key you set replaces the setup's value for that key as a whole, and the keys you leave out keep the setup's values.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.