How to do Meta ads conversion tracking in WhatsApp bot using the Conversion API

Cesar Banchio Updated by Cesar Banchio

This guide explains how to send events to Metaโ€™s Conversions API (CAPI) using the Graph API, in WhatsApp bots. This is useful for tracking conversions (e.g. leads, purchases, signups) after a user interacts with your bot.

๐Ÿ” Hashing Sensitive Fields

Meta requires all personal identifiers (like email and phone) to be SHA-256 hashed before sending. This is crucial for protecting user data and enabling accurate matching.

๐Ÿ‘‰ Always lowercase and trim the data before hashing.

The data collection process on the bot would look like so:

We capture the information and with a formula block we use the Lower method to transform to lower case.

Next, we hash the data.

External Hashing API (No Code)

You can hash values using this free SHA-256 API

GET https://api.hashify.net/hash/sha256/hex?value=testvalue

Use a Webhook block to call this API.

Save the returned Digest into a new field (e.g. @sha_name).

๐Ÿ“ Note: Each webhook call hashes one field at a time. You'll need separate Webhook blocks for each identifier (email, phone, etc.).

๐Ÿ“… Generate Unix Timestamp

To generate a timestamp in your bot, use a Set Variable block with ${timestamp}

this gives the current Unix time, but includes a decimal (e.g., 1721101234.0).

To remove the decimal, follow it with a Formula block using: Replace(@timestamps, ".0", "")

This converts the value to a clean integer format (1721101234), which is required by APIs like Metaโ€™s Conversions API for the event_time field.

๐Ÿ“ค Send Data to Convertions API

Once we have collected and hashed all the information we want to send to Conversions API, we will use Graph API to send the data. This is the endpoint

POST https://graph.facebook.com/v18.0/<PIXEL_ID>/events?access_token=<ACCESS_TOKEN>

Example of payload

{
"data": [
{
"event_name": "Lead",
"event_time": 1720515610,
"user_data": {
"em": "@sha_email",
"ph": "@sha_phone",

"client_user_agent": "WhatsAppBot/1.0",

}

}
]
}

Notes

event_time: Unix timestamp (in seconds)

user_data: must be SHA-256 hashed

For more information, you can review the Conversions API documentation

Was this article helpful?

WhatsApp - Get user out of error message loop

Contact