Meta Conversions API (CAPI) Server-Side Tracking - n8n Workflow

Use this n8n workflow to implement accurate server-side tracking for Meta Ads (Facebook) Conversions API (CAPI). Securely hash PII and send conversion events.

Workflow Preview

Ready to automate?

Download this n8n workflow template and start using it instantly.

Who is this best for?

Marketing technologists needing resilient conversion tracking.
E-commerce businesses aiming to bypass browser restrictions (ad blockers, iOS privacy).
Developers looking for robust server-side synchronization n8n templates.
Anyone seeking to automate data processing and secure PII handling within an n8n workflow.

Overview

Modern privacy regulations and browser limitations (like ad blockers and iOS tracking prevention) severely impact the accuracy of web-based conversion tracking. This specialized n8n workflow provides a solution by implementing the Meta Conversions API (CAPI) via a server-side endpoint.

By leveraging this n8n workflow, you ensure that valuable conversion data (such as leads or purchases) is processed securely. The core value of this n8n template lies in its compliance: it automatically normalizes and hashes Personally Identifiable Information (PII) like email and phone number using SHA256 before transmission, meeting Meta's strict requirements for data privacy. This robust approach drastically improves ad attribution accuracy, enabling better optimization for your Meta advertising campaigns.

How it Works

The entire process is initiated by an external event sending data to the n8n trigger node.


  1. Incoming Data Trigger: The process starts when a client (like a website or backend service) sends a POST request to the Webhook n8n trigger. This request must include PII (email, phone, names) and tracking cookies (fbc, fbp).

  2. Data Normalization and Cleaning: The incoming data is passed through a Set n8n node, which cleans up the PII (e.g., lowercases emails and removes non-digit characters from phone numbers) to ensure standardization.

  3. Secure Hashing: A sequence of Crypto n8n nodes uses SHA256 hashing to securely anonymize the normalized PII fields (email, phone, first name, last name), which is mandatory for the CAPI.

  4. Payload Preparation: A subsequent Set n8n node calculates the current UNIX timestamp and maps the required conversion fields, including the hashed PII and tracking cookies (fbp, fbc).

  5. CAPI Structuring: A custom Code n8n node takes the mapped data and structures it into the precise JSON format required by the Meta CAPI, nesting user data and event information correctly.

  6. Send Conversion Event: An HTTP Request n8n node securely transmits the final, structured payload to the Meta Graph API endpoint using a Bearer token (the CAPI Access Token).

  7. Response: The n8n workflow concludes by sending a 200 OK response back to the original client using the Respond to Webhook n8n node.

Installation Guide

To install and activate this Meta CAPI n8n workflow, follow these steps:


  1. Import: Copy the provided JSON data and import it directly into your n8n instance via the Workflows section (New -> Import from JSON).

  2. Configure Webhook: Click the 'Webhook' n8n trigger node and copy the Test or Production URL. This is the endpoint where your website or backend system must send conversion data.

  3. Set Event Name: In the 'Set - Compute Timestamps & Map Fields' n8n node, review the eventname assignment. If your event is not 'SubmitApplication' (e.g., 'Purchase' or 'Lead'), update the string value accordingly.

  4. Configure Meta API Node: Locate the 'Sending Events To Facebook Pixel' n8n node.

URL Update: In the URL field, replace the placeholder PIXELID_HERE with your actual Meta Pixel ID.
Authentication: Go to the Authentication tab. Select 'HTTP Bearer Auth' and create a new credential. Paste your CAPI Access Token, generated in the Meta Events Manager, into the Token field.

Node Details

Webhook (n8n trigger): This is the starting point, configured to listen for POST requests at a specific path (meta-conversion-api). It receives raw conversion data from your external application.
Edit Normalize PII (Set n8n node): Essential for data quality. It cleans up user inputs (e.g., trimming whitespace and ensuring email/names are lowercase) before hashing.
Crypto - Hash Email/Phone/Name (Crypto n8n node): A series of nodes dedicated to security. They take the normalized PII and apply the mandatory SHA256 hash, preparing the data for compliance with Meta standards.
Set - Compute Timestamps & Map Fields (Set n8n node): Responsible for combining metadata. It computes the current conversion_timestamp and maps fields like fbc, fbp, IP address, and user agent, alongside the newly hashed PII.
Preparing for HTTP Request Payload (Code n8n node): This crucial n8n node uses custom JavaScript to transform the input data into the exact data array structure expected by the Meta Conversions API.
Sending Events To Facebook Pixel (HTTP Request n8n node): The final action node. It executes the POST request to the Meta Graph API, utilizing the Bearer Token credential for authorization and sending the structured conversion payload.

Related n8n Workflows

Free

Nodes: 7 Nodes
Updated: December 26 2025
View all
Created by

Founder of Osinity. I build AI-powered n8n automations that save businesses 10+ hours a week and grow their revenue. We guarantee results with a 30-day risk-free trial—you only pay when we hit your targets.

Featured*