AutomationFlowsMarketing & Ads › Facebook/meta Conversion API for Ecommerce Leads/orders

Facebook/meta Conversion API for Ecommerce Leads/orders

ByOmar Akoudad @mediaplusma on n8n.io

This n8n workflow helps eCommerce businesses (especially in the Cash on Delivery space) send real-time order events to the Meta (Facebook) Conversions API, ensuring accurate event tracking and better ad attribution. Webhook Listener: Accepts incoming order data (name, phone, IP,…

Webhook trigger★★★★☆ complexity17 nodesFacebook Graph Api
Marketing & Ads Trigger: Webhook Nodes: 17 Complexity: ★★★★☆ Added:

This workflow corresponds to n8n.io template #5136 — we link there as the canonical source.

The workflow JSON

Copy or download the full n8n JSON below. Paste it into a new n8n workflow, add your credentials, activate. Full import guide →

Download .json
{
  "nodes": [
    {
      "id": "7fd5ddfd-a858-4a0a-84b8-f8f4ec034d63",
      "name": "Normalize data",
      "type": "n8n-nodes-base.set",
      "position": [
        -60,
        0
      ],
      "parameters": {
        "include": "except",
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "65d1994d-f4b8-478a-8cf1-490990e6639d",
              "name": "user_data.phone",
              "type": "string",
              "value": "={{$json.user_data.phone.replace(/\\D/g, '').replace(/^0+/, '')}}"
            },
            {
              "id": "5650546d-f0ad-4c69-829c-3e4283e16ac7",
              "name": "event_time",
              "type": "number",
              "value": "={{Math.floor(new Date($json.event_time).getTime() / 1000)}}"
            },
            {
              "id": "9475d631-348f-4d53-9e75-0d568654aeef",
              "name": "user_data.first_name",
              "type": "string",
              "value": "={{$json.user_data.first_name}}"
            },
            {
              "id": "77a8f321-abf9-4618-8fb2-ef5d567a9cd1",
              "name": "user_data.last_name",
              "type": "string",
              "value": "={{$json.user_data.last_name}}"
            }
          ]
        },
        "excludeFields": "user_data.name",
        "includeOtherFields": true
      },
      "typeVersion": 3.4
    },
    {
      "id": "978d3854-44f6-4773-928e-4536a97a48b1",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -180,
        -60
      ],
      "parameters": {
        "color": 7,
        "width": 343,
        "height": 252,
        "content": "## Data normalization"
      },
      "typeVersion": 1
    },
    {
      "id": "feb4a686-278f-41d4-ab13-ba4fbc159ef6",
      "name": "Encrypt data",
      "type": "n8n-nodes-base.set",
      "position": [
        300,
        0
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "097ed7ff-c076-454e-930c-1f4820ac6e2e",
              "name": "user_data.first_name",
              "type": "string",
              "value": "={{ $json.user_data.first_name.hash(\"sha256\") }}"
            },
            {
              "id": "e285fa12-d272-48a0-a583-5e90b394fd74",
              "name": "user_data.last_name",
              "type": "string",
              "value": "={{ $json.user_data.last_name.hash(\"sha256\") }}"
            },
            {
              "id": "1e87a997-5b78-48d8-9616-edfb1b910743",
              "name": "user_data.phone",
              "type": "string",
              "value": "={{ $json.user_data.phone.hash(\"sha256\") }}"
            }
          ]
        },
        "includeOtherFields": true
      },
      "typeVersion": 3.4
    },
    {
      "id": "1beb8a7c-0bce-489a-aea4-c2acb937601f",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        180,
        -60
      ],
      "parameters": {
        "color": 7,
        "width": 343,
        "height": 252,
        "content": "## Data encryption\n"
      },
      "typeVersion": 1
    },
    {
      "id": "9f867c8b-fdc1-4294-b56e-12340c604111",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        680,
        -220
      ],
      "parameters": {
        "color": 7,
        "width": 375,
        "height": 414,
        "content": "## Send event\nYou can use a test code from Facebook Events Manager to verify your integration.\n\nAdd your test code to the test_code parameter inside the JSON payload.\n\nOnce everything is confirmed to be working, remove the test_event_code so that events are officially logged.\n\n[**Read more**](https://business.facebook.com/business/help/2040882565969969)"
      },
      "typeVersion": 1
    },
    {
      "id": "c00c1fac-7550-4fa9-8fc9-e9f250519e6a",
      "name": "Send event to Meta",
      "type": "n8n-nodes-base.facebookGraphApi",
      "position": [
        820,
        20
      ],
      "parameters": {
        "edge": "events",
        "node": "={{$('Format data').item.json.pixel_id}}",
        "options": {
          "queryParametersJson": "={\n  \"data\": [\n    {\n      \"event_name\": \"{{ $('Encrypt data').item.json.event_name }}\",\n      \"event_time\": {{ $('Encrypt data').item.json.event_time }},\n      \"event_source_url\": \"{{ $('Encrypt data').item.json.event_source_url }}\",\n      \"action_source\": \"{{ $('Encrypt data').item.json.action_source }}\",\n      \"user_data\": {\n        \"em\": \"{{ $('Encrypt data').item.json.user_data.email }}\",\n        \"ph\": \"{{ $('Encrypt data').item.json.user_data.phone }}\",\n        \"fn\": \"{{ $('Encrypt data').item.json.user_data.first_name }}\",\n        \"ln\": \"{{ $('Encrypt data').item.json.user_data.last_name }}\",\n        \"fbc\": \"{{ $('Encrypt data').item.json.user_data.fbp }}\",\n        \"fbp\": \"{{ $('Encrypt data').item.json.user_data.fbc }}\",\n        \"ip\": \"{{ $('Encrypt data').item.json.user_data.ip }}\",\n        \"user_agent\": \"{{ $('Encrypt data').item.json.user_data.user_agent }}\"\n      },\n      \"custom_data\": {\n        \"value\": {{ $('Encrypt data').item.json.custom_data.value }},\n        \"currency\": \"{{ $('Encrypt data').item.json.custom_data.currency }}\"\n      }\n    }\n  ],\n  \"test_event_code\": \"TEST1337\"\n}\n"
        },
        "graphApiVersion": "=v20.0",
        "httpRequestMethod": "POST"
      },
      "credentials": {
        "facebookGraphApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "5b486767-1ec1-4829-a556-ddc4f0c13f95",
      "name": "Webhook",
      "type": "n8n-nodes-base.webhook",
      "position": [
        -1260,
        -240
      ],
      "parameters": {
        "path": "b408defb-315d-4676-b4c4-1dcebe81ffc0",
        "options": {},
        "httpMethod": [
          "POST",
          "GET"
        ],
        "multipleMethods": true
      },
      "typeVersion": 2
    },
    {
      "id": "8a8ee5fb-edf4-410c-b86c-a1b805a66319",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1160,
        100
      ],
      "parameters": {
        "height": 220,
        "content": "## Test data \nYou can chenge test data here"
      },
      "typeVersion": 1
    },
    {
      "id": "40240bfc-8e7b-4c5b-84e0-b8ccd52b097e",
      "name": "Test data",
      "type": "n8n-nodes-base.code",
      "position": [
        -1100,
        180
      ],
      "parameters": {
        "jsCode": "return {\n  \"body\": {\n    'first_name': \"Alex\",\n    'last_name': \"Forbic\",\n    'phone': \"+1234567890\",\n    'ip': \"0.0.0.0\",\n    'user_agent': \"Mozilla/5.0 (Linux; Android 14; SM-A065F Build/UP1A.231005.007; )\",\n    'fbp': \"fb.1.1750638230973.IwZXh0bgNhZW0BMABhZGlkAasgzcY0SboBHlIpXRPFXRua8Udfs9qnBwf4GN3xGWPk9HvipTCJeUYt8jaENcQyAm_TYaYITPrWtzJcJ8e38-CMQ\",\n    'fbc': \"fb.1.1750612363841.918837434857767253\",\n    'created_at': \"2025-06-18T15:24:06.000000Z\",\n    'amount': 120,\n    'currency': \"EUR\"\n  }\n};"
      },
      "notesInFlow": true,
      "typeVersion": 2
    },
    {
      "id": "dbb5d646-4500-4ed9-89b6-607ebfc216d9",
      "name": "Sticky Note5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1620,
        80
      ],
      "parameters": {
        "height": 240,
        "content": "## Test Workflow\nClick this button to test the workflow with fake data \n"
      },
      "typeVersion": 1
    },
    {
      "id": "8473264d-fbad-4213-a0bf-84e7f841053e",
      "name": "Execute workflow",
      "type": "n8n-nodes-base.manualTrigger",
      "position": [
        -1540,
        180
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "ad465243-cb30-492d-b77c-1066fec33c1b",
      "name": "Sticky Note6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -640,
        -220
      ],
      "parameters": {
        "color": 7,
        "width": 340,
        "height": 80,
        "content": "## Change here\n"
      },
      "typeVersion": 1
    },
    {
      "id": "1b1c1cd5-ecfe-40d2-af82-1b0cc2b65e7c",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -640,
        -120
      ],
      "parameters": {
        "color": 7,
        "width": 343,
        "height": 312,
        "content": "## Collect data\nIn this node you link between your webhook data with this node parameters, also you can add more data."
      },
      "typeVersion": 1
    },
    {
      "id": "63208dd1-6258-4630-9c3b-c8913cf04085",
      "name": "Format data",
      "type": "n8n-nodes-base.code",
      "position": [
        -520,
        0
      ],
      "parameters": {
        "jsCode": "return [\n  {\n    json: {\n      event_name: \"Purchase\",\n      pixel_id:'1714041194725552', // you pixel ID\n      user_data: {\n        first_name: $input.first().json.body.first_name, // your customer first_name\n        last_name: $input.first().json.body.last_name, // your customer last_name\n        phone: $input.first().json.body.phone, // your customer phone\n        ip: $input.first().json.body.ip, // your customer IP\n        user_agent: $input.first().json.body.user_agent, // your customer User agent\n        fbp: $input.first().json.body.fbp, // your customer fbp\n        fbc: $input.first().json.body.fbc // your customer fbc\n      },\n      event_time: $input.first().json.body.created_at, // order Date like 2025-06-18T15:24:06.000000Z\n      custom_data: {\n        value: $input.first().json.body.amount, // pricing\n        currency: $input.first().json.body.currency\n      },\n      action_source: \"website\",\n      event_source_url: \"https://example.com/thanks\"\n    }\n  }\n];"
      },
      "typeVersion": 2
    },
    {
      "id": "81bb1144-9e20-41d2-a611-c5f2422cba09",
      "name": "Sticky Note7",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -640,
        360
      ],
      "parameters": {
        "color": 4,
        "width": 1700,
        "height": 100,
        "content": "## Do you need more help or have any suggestions?\nContact me at mediaplus.ma@gmail.com"
      },
      "typeVersion": 1
    },
    {
      "id": "a959b199-3d42-4a97-9c59-17cfa0b48124",
      "name": "Sticky Note8",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1620,
        340
      ],
      "parameters": {
        "width": 700,
        "height": 80,
        "content": "## Just to test"
      },
      "typeVersion": 1
    },
    {
      "id": "541e0afe-1fd4-4c5e-a8e9-d7aa6f0e5832",
      "name": "Sticky Note9",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1300,
        -320
      ],
      "parameters": {
        "color": 4,
        "width": 200,
        "height": 240,
        "content": "## Production"
      },
      "typeVersion": 1
    }
  ],
  "connections": {
    "Webhook": {
      "main": [
        [
          {
            "node": "Format data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Test data": {
      "main": [
        [
          {
            "node": "Format data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Format data": {
      "main": [
        [
          {
            "node": "Normalize data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Encrypt data": {
      "main": [
        [
          {
            "node": "Send event to Meta",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Normalize data": {
      "main": [
        [
          {
            "node": "Encrypt data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Execute workflow": {
      "main": [
        [
          {
            "node": "Test data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}

Credentials you'll need

Each integration node will prompt for credentials when you import. We strip credential IDs before publishing — you'll add your own.

Pro

For the full experience including quality scoring and batch install features for each workflow upgrade to Pro

About this workflow

This n8n workflow helps eCommerce businesses (especially in the Cash on Delivery space) send real-time order events to the Meta (Facebook) Conversions API, ensuring accurate event tracking and better ad attribution. Webhook Listener: Accepts incoming order data (name, phone, IP,…

Source: https://n8n.io/workflows/5136/ — original creator credit. Request a take-down →

More Marketing & Ads workflows → · Browse all categories →

Related workflows

Workflows that share integrations, category, or trigger type with this one. All free to copy and import.

Marketing & Ads

Ad Agency in a box. Uses httpRequest, splitOut, outputParserStructured, chainLlm. Webhook trigger; 54 nodes.

HTTP Request, Output Parser Structured, Chain Llm +5
Marketing & Ads

This workflow automates bulk email campaigns with built-in validation, deliverability protection, and smart send-time optimization.

HTTP Request, Postgres, Gmail
Marketing & Ads

Who is this for? Solo founders, sales teams, and event organizers who need email outreach without expensive tools but want full control from Telegram.

Telegram, Google Sheets, Google Sheets Trigger +2
Marketing & Ads

This workflow is designed to manage the assignment and validation of unique QR code coupons within a lead generation system with SuiteCRM.

HTTP Request, Form Trigger, Google Sheets +1
Marketing & Ads

This workflow acts as an instant SDR that replies to new inbound leads across multiple channels in real time. It first captures and normalizes all incoming lead data into a unified structure. The work

Google Sheets, HTTP Request, Gmail +1