Secure eCommerce Conversion Tracking for Meta/Facebook - n8n Workflow

Use this powerful n8n workflow to securely send hashed eCommerce Purchase or Lead events to the Meta Conversion API, ensuring privacy compliance and accurate ad attribution.

Workflow Preview

Ready to automate?

Download this n8n workflow template and start using it instantly.

Who is this best for?

• eCommerce store owners requiring precise ad performance tracking.
• Digital marketers needing a compliant way to utilize the Meta/Facebook Conversion API.
• Technical teams looking for robust, self-hosted n8n templates for advertising integrations.
• Users seeking to implement advanced server-side tracking using an n8n node structure.

Overview

Maintaining accurate marketing attribution while respecting user privacy is essential for modern eCommerce. This specialized n8n workflow addresses this challenge by providing a complete server-side tracking solution. Unlike browser-side pixels, this n8n automation ensures reliable event delivery to Meta (Facebook), bypassing ad-blockers and browser limitations. The core value of this n8n template lies in its built-in data handling: it automatically cleans, normalizes, and applies SHA256 hashing to Personally Identifiable Information (PII) like phone numbers and names before transmission, adhering to Meta’s data privacy requirements. This specific n8n workflow starts with a flexible n8n trigger, ready to ingest data from any platform via webhook, making it an indispensable tool for maximizing ad campaign effectiveness.

How it Works

The conversion tracking process is initiated either by a real-time event captured by the Webhook n8n trigger (for production use) or by the Execute workflow manual n8n trigger for testing purposes.


  1. Data Ingestion: Incoming customer data (like purchase details, customer identifiers, and timestamps) is received.

  2. Data Mapping: The Format data n8n node takes the raw input and maps it to the specific structure required by the Meta Conversion API, defining the eventname (e.g., Purchase) and associating the required pixelid.

  3. Normalization: The Normalize data n8n node cleans up PII fields. Critically, it scrubs the phone number field of non-digit characters and converts the human-readable timestamp into the Unix epoch integer format required by the Meta API.

  4. Encryption: The Encrypt data n8n node applies SHA256 hashing to sensitive fields (firstname, lastname, phone). This essential step ensures data compliance before external transmission.

  5. Event Submission: The final Send event to Meta n8n node uses the Facebook Graph API credential to securely post the fully structured, compliant, and hashed event payload to Meta’s servers, ensuring the conversion is accurately attributed to the ad campaign. Note that this specific n8n template includes a testeventcode for initial verification.

Installation Guide

To deploy and utilize this powerful n8n workflow, follow these steps:


  1. Import: Copy the provided JSON data and import it directly into your self-hosted or cloud n8n instance using the 'New' -> 'Import from JSON' option.

  2. Set Up Credentials: You will need a valid Facebook Graph API credential for the Send event to Meta n8n node. This typically requires a System User Access Token with adsmanagement or similar permissions.

  3. Configure Pixel ID: Open the Format data n8n node (a Code node) and replace the placeholder pixelid (1714041194725552) with your actual Meta Pixel ID.

  4. Setup Webhook: Activate the Webhook n8n trigger node. Copy the generated URL and configure your eCommerce platform (or data source) to send conversion event data to this endpoint via POST request.

  5. Testing (Important): Run the n8n workflow using the Execute workflow n8n trigger. Verify the data lands in your Meta Events Manager test tool using the testeventcode (TEST1337).

  6. Go Live: Once confirmed, remove the testeventcode from the payload in the Send event to Meta n8n node to start sending live production events.

Node Details

Webhook (n8n trigger): The primary entry point for production data. It waits for incoming POST or GET requests containing raw conversion data.
Test data (Code n8n node): Provides standardized dummy data (names, phone, IP, FBP/FBC tokens, amounts) for quick testing of the n8n workflow logic without external input.
Format data (Code n8n node): Essential mapping n8n node. It extracts required fields from the input and structures them into the Meta Conversion API format, setting the eventname ('Purchase') and configuring the target pixelid.
Normalize data (Set n8n node): Performs data cleansing. Key configuration includes using a regular expression to clean phone numbers and a JavaScript expression (Math.floor(new Date($json.eventtime).getTime() / 1000)) to convert the timestamp format required by the API.
Encrypt data (Set n8n node): Handles privacy compliance. This n8n node applies SHA256 hashing to userdata.firstname, userdata.lastname, and userdata.phone using the hash("sha256") expression method.
Send event to Meta (Facebook Graph API n8n node): The final action. It uses a dynamic expression for the Pixel ID and posts the complete conversion event data, including the necessary custom data fields and hashed user identifiers.

Related n8n Workflows

Free

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

Automation, Code, and Analytics for E-commerce businesses, We help businesses streamline operations using n8n, AI agents, and data science to enhance efficiency and scalability.

Featured*