Meta Pixel
With Meta Pixel you can track visitor activity on a website and track conversions to appear in the Meta Ads Manager.
Installation
- TypeScript
- Script
- Code
Install the destination via npm
npm i @elbwalker/destination-web-meta-pixel
import { elb } from '@elbwalker/walker.js';
import destinationMetaPixel from '@elbwalker/destination-web-meta-pixel';
elb('walker destination', destinationMetaPixel, config);
Load the destination via dynamic import
<script>
// Upload the dist/index.mjs on your own server
const destination = (
await import(
'https://cdn.jsdelivr.net/npm/@elbwalker/destination-web-meta-pixel/dist/index.mjs'
)
).default;
elb('walker destination', destination, config);
</script>
Copy the code from the index.browser.js file
(function () {
'use strict';
var Destination = (() => {})(); // This is the copied code
elb('walker destination', Destination.default, config);
})();
Configuration
Configure your meta pixel destination with your Pixel ID.
Example
const config = {
custom: {
pixelId: '1234567890', // Required
},
mapping: {
order: {
complete: {
name: 'Purchase',
data: {
map: {
currency: { value: 'EUR' },
value: 'data.total',
contents: {
loop: [
'nested',
{
map: {
id: 'data.id',
quantity: { key: 'data.quantity', value: 1 },
},
},
],
},
content_type: { value: 'product' },
},
},
},
},
},
};
Custom
Property | Type | Description |
---|---|---|
pixelId* | string | Ads account ID used for every conversion |
currency | string | Default currency for conversions |
pageview | boolean | Whether to send the PageView event |
Properties with a *
are required.
CustomEvent
For the custom event mapping (mapping.entity.action.custom
):
For track
, use one of the official
standard event names,
otherwise trackCustom
will be used.
Property | Type | Description |
---|---|---|
content_ids | string | Data property key to use in content_ids, e.g., "data.product_ids". |
content_name | string | Data property key to use as content_name, e.g., "data.product_name". |
content_type | string | Type of content, e.g., "product". |
contents | object | Contains id and quantity for content, accessible via wildcard. |
track | string | Standard event to track, e.g., "Purchase". |
value | string | Data property key for value, e.g., "data.value". |
contents
is an object with the following properties:
id
: PropertyMapping (string
or object withkey
and optionaldefault
)quantity
: PropertyMapping (string
or object withkey
and optionaldefault
)
info
If you need professional support with your walkerOS implementation, check out our services.