Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/edgee-cloud/meta-capi-component
Meta CAPI Edgee component
https://github.com/edgee-cloud/meta-capi-component
data-collection edge edge-computing edgee facebook meta rust wasm wasm-component
Last synced: about 4 hours ago
JSON representation
Meta CAPI Edgee component
- Host: GitHub
- URL: https://github.com/edgee-cloud/meta-capi-component
- Owner: edgee-cloud
- License: apache-2.0
- Created: 2024-12-29T06:10:13.000Z (15 days ago)
- Default Branch: main
- Last Pushed: 2025-01-06T08:06:32.000Z (7 days ago)
- Last Synced: 2025-01-06T09:22:24.073Z (7 days ago)
- Topics: data-collection, edge, edge-computing, edgee, facebook, meta, rust, wasm, wasm-component
- Language: Rust
- Homepage: https://www.edgee.cloud
- Size: 155 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
- Security: SECURITY.md
Awesome Lists containing this project
README
Meta CAPI Component for Edgee
This component implements the data collection protocol between [Edgee](https://www.edgee.cloud) and [Meta CAPI](https://developers.facebook.com/docs/marketing-api/conversions-api/).
## Quick Start
1. Download the latest component version from our [releases page](../../releases)
2. Place the `meta_capi.wasm` file in your server (e.g., `/var/edgee/components`)
3. Add the following configuration to your `edgee.toml`:```toml
[[destinations.data_collection]]
name = "meta_capi"
component = "/var/edgee/components/meta_capi.wasm"
credentials.meta_access_token = "YOUR_ACCESS_TOKEN"
credentials.meta_pixel_id = "YOUR_PIXEL_ID"
credentials.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:
```javascript
edgee.user({
user_id: "123",
properties: {
email: "[email protected]",
},
});
```## Configuration Options
### Basic Configuration
```toml
[[destinations.data_collection]]
name = "meta_capi"
component = "/var/edgee/components/meta_capi.wasm"
credentials.meta_access_token = "YOUR_ACCESS_TOKEN"
credentials.meta_pixel_id = "YOUR_PIXEL_ID"
credentials.meta_test_event_code = "TEST_EVENT_CODE" # Optional# Optional configurations
config.default_consent = "pending" # Set default consent status
```### Event Controls
Control which events are forwarded to Meta CAPI:
```toml
config.page_event_enabled = true # Enable/disable page view tracking
config.track_event_enabled = true # Enable/disable custom event tracking
config.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:
```javascript
edgee.consent("granted");
```Or using the Data Layer:
```html{
"data_collection": {
"consent": "granted"
}
}```
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](https://www.rust-lang.org/tools/install)
- WASM target: `rustup target add wasm32-wasip2`
- wit-deps: `cargo install wit-deps`Build command:
```bash
make wit-deps
make build
```### Contributing
Interested in contributing? Read our [contribution guidelines](./CONTRIBUTING.md)### Security
Report security vulnerabilities to [[email protected]](mailto:[email protected])
```