# Meta Pixel (Facebook).

> Source: https://docs.gifty.nl/en/order-widget/installation/meta-pixel-facebook
> Language: en

The pixel integration makes it possible to measure various [standard events](https://developers.facebook.com/docs/meta-pixel/reference#standard-events) from the order module. By enabling the integration, events are sent to the FBQ tag that is already present on the page.

The following three events are supported: `ViewContent`, `AddToCart` and `Purchase`.

---

<a id="installation"></a>

## Installation

To enable the events, modify the Gifty script by adding the fbq property and setting it to true.

The events are sent to the Meta pixel on pages where the order module is displayed. The Meta pixel must already be installed on those pages.

```html
<script>
window.Gifty = {
  key: 'WIDGET_KEY_HERE',
  fbq: true
};
(function (e, t) {
	var n = e.createElement(t);
	n.async = true;
	n.src = 'https://static.gifty.nl/js/widget.js';
	var r = e.getElementsByTagName(t)[0];
	r.parentNode.insertBefore(n, r);
})(document, 'script');
</script>
```

---

<a id="events"></a>

## Events

The events `ViewContent`, `AddToCart` and `Purchase` are supported. Below you will find when we'll send the event and what data the event contains.

| Event | When | Properties |
| --- | --- | --- |
| ViewContent | Order module viewed | currency, content_category |
| AddToCart | Product (gift card or package deal) added to the order | value, currency, content_ids, content_name, content_type, contents |
| Purchase | After placing an order | value, currency, content_type, contents, num_items |

<a id="viewcontent"></a>

### ViewContent

An example of data that is sent when the order module is viewed.

```js
fbq('track', 'ViewContent', {
    currency: 'EUR',
    content_category: 'Gift Cards',
});
```

<a id="addtocart"></a>

### AddToCart

An example of data that is sent when a product is added to the order.

```js
fbq('track', 'AddToCart', {
    currency: 'EUR',
    value: 25.95,
    content_ids: ['package-PACKAGE_ID-ORGANIZATION_ID-2595'],
    content_name: 'Gift Card',
    content_type: 'product',
    contents: [
        {
            id: 'package-PACKAGE_ID-ORGANIZATION_ID-2595',
            quantity: 1,
        }
    ]
});
```

<a id="purchase"></a>

### Purchase

An example of data that is sent once an order has been placed.

```js
fbq('track', 'Purchase', {
    currency: 'EUR',
    value: 50.95,
    content_type: 'product',
    contents: [
        {
            id: 'package-PACKAGE_ID-ORGANIZATION_ID-2595',
            quantity: 1,
        },
        {
            id: 'gift-card-ORGANIZATION_ID-2500',
            quantity: 1,
        }
    ],
    num_items: 2,
});
```
