Skip to content

edgee-cloud/meta-capi-component

Meta CAPI Component for Edgee

This component implements the data collection protocol between Edgee and Meta CAPI.

Quick Start

  1. Download the latest component version from our releases page
  2. Place the meta_capi.wasm file in your server (e.g., /var/edgee/components)
  3. Add the following configuration to your edgee.toml:
[[components.data_collection]]
id = "meta_capi"
file = "/var/edgee/components/meta_capi.wasm"
settings.meta_access_token = "YOUR_ACCESS_TOKEN"
settings.meta_pixel_id = "YOUR_PIXEL_ID"
settings.meta_test_event_code = "TEST_EVENT_CODE" # Optional

Event Handling

Event Mapping

The component maps Edgee events to Meta CAPI events as follows:

Edgee event Meta CAPI Event Description
Page PageView Triggered when a user views a page
Track Name of the event Uses the provided event name directly
User Lead Used for lead identification

User Event Handling

User events in Meta CAPI serve multiple purposes:

  • Triggers an Lead call to Meta CAPI
  • Stores user_id, anonymous_id, and properties on the user's device
  • Enriches subsequent Page and Track events with user data
  • Enables proper user attribution across sessions

BE CAREFUL: Meta Conversions API is designed to create a connection between an advertiser’s marketing data (such as website events) and Meta systems that optimize ad targeting, decrease cost per result and measure outcomes. Each event you send to Meta CAPI must have a user property (at least one of the following: email, phone_number), otherwise the event will be ignored.

Here is an example of a user call:

edgee.user({
  user_id: "123",
  properties: {
    email: "john.doe@example.com",
  },
});

Configuration Options

Basic Configuration

[[components.data_collection]]
id = "meta_capi"
file = "/var/edgee/components/meta_capi.wasm"
settings.meta_access_token = "YOUR_ACCESS_TOKEN"
settings.meta_pixel_id = "YOUR_PIXEL_ID"
settings.meta_test_event_code = "TEST_EVENT_CODE" # Optional

# Optional configurations
settings.edgee_default_consent = "pending" # Set default consent status

Event Controls

Control which events are forwarded to Meta CAPI:

settings.edgee_page_event_enabled = true   # Enable/disable page view tracking
settings.edgee_track_event_enabled = true  # Enable/disable custom event tracking
settings.edgee_user_event_enabled = true   # Enable/disable user identification

Consent Management

Before sending events to Meta CAPI, you can set the user consent using the Edgee SDK:

edgee.consent("granted");

Or using the Data Layer:

<script id="__EDGEE_DATA_LAYER__" type="application/json">
  {
    "data_collection": {
      "consent": "granted"
    }
  }
</script>

If the consent is not set, the component will use the default consent status. Important: Meta CAPI requires the consent status to be set to granted. If not, the events will be ignored.

Consent Events
pending ignored
denied ignored
granted forwarded

Development

Building from Source

Prerequisites:

  • Rust
  • WASM target: rustup target add wasm32-wasip2
  • wit-deps: cargo install wit-deps

Build command:

make wit-deps
make build

Contributing

Interested in contributing? Read our contribution guidelines

Security

Report security vulnerabilities to security@edgee.cloud