Growth

Meta Ads

CognitionDesk integrates with the Meta Marketing API and Conversions API via the facebook-nodejs-business-sdk, enabling programmatic ad management, lead tracking, and server-side conversion events.

Capabilities

  • Campaign management — create, update, and monitor campaigns and ad sets
  • Lead tracking — capture leads from Meta Lead Forms and sync to Firestore
  • Conversion events — send purchase and custom events via Meta Conversions API
  • Analytics — retrieve performance metrics (impressions, clicks, CPL, ROAS)

Create a campaign

JSON
POST /meta-ads/campaigns
Authorization: Bearer <token>

{
  "adAccountId": "act_123456789",
  "name": "Spring Sale 2026",
  "objective": "LEAD_GENERATION",
  "status": "PAUSED",
  "budget": {
    "type": "daily",
    "amount": 50,
    "currency": "USD"
  }
}

Track a lead

JSON
POST /meta-ads/leads/track
Authorization: Bearer <token>

{
  "campaignId": "23856...",
  "leadData": {
    "name": "Jane Smith",
    "email": "jane@example.com",
    "phone": "+1234567890"
  },
  "source": "lead_form"
}

Send conversion events

All user data must be hashed (SHA-256) before sending to comply with Meta's data policies:

JSON
// Send conversion events to Meta's Conversions API
POST /meta-ads/conversions
Authorization: Bearer <token>

{
  "pixelId": "123456789",
  "eventName": "Purchase",
  "eventTime": 1700000000,
  "userData": {
    "email": "sha256_hashed_email",
    "phone": "sha256_hashed_phone"
  },
  "customData": {
    "value": 149.99,
    "currency": "USD",
    "orderId": "ORD-12345"
  }
}

Setup required

Meta Ads features require a connected Meta Business account with the appropriate API permissions. Run GET /diagnostic/facebook-app to verify your app configuration.

Meta Ads — CognitionDesk Docs