---
title: "Ad tracking and sending purchase event to Facebook"
description: "Step-by-step guide to create an App in Meta, set up use cases, generate system token, required permissions, and create/query dataset via API using WABA ID."
url: https://help.datacrazy.io/en/articles/10670775-ad-tracking-and-sending-purchase-event-to-facebook
collection: "Automations"
updated: 2026-11-18
language: en
alternates: [pt-br, es]
---

# Ad tracking and sending purchase event to Facebook

Step-by-step guide to create an App in Meta, set up use cases, generate system token, required permissions, and create/query dataset via API using WABA ID.

App Creation, Token Generation And Dataset (whats App + Marketing Api)

* * *

## The goal of this guide is to complement the video below

We’re not creating the App for direct functional use, but rather to:

-   🔐 Generate a **reliable system token**
    
-   🔗 Integrate this token with **CRM Datacrazy**
    
-   📊 Track leads coming from ads (**Tracking #1**)
    
-   🛒 Send purchase events to the WhatsApp Pixel (**Tracking #2**)
    

This token is the foundation of the entire tracking integration with Meta.

NOTE: For better sampling of metrics, and in a more accurate way, you need to create a messages campaign with PURCHASE OBJECTIVE.

Message campaigns with the objective of maximizing the number of conversations will not show PURCHASE conversion according to META support.

* * *

## Step 1 – Create the APP

### Use cases when creating the App

While creating the App, select the following **main use cases**:

-   Create and manage ads with the **Marketing API**
    
-   Connect with customers via **WhatsApp**
    
-   Manage everything through your **Facebook Page**
    

### Additional use cases (required)

After creating the App, also add:

-   **read\_insights**  
    Path: _Manage Pages_ → click on **ADD**
    
-   **whatsapp\_business\_manage\_events**  
    Path: _Connect on WhatsApp_ → click on **ADD**
    

> ⚠ These use cases are necessary to release permissions that will be used in the token.

* * *

## Step 2 – Set up the App’s required links

In the App settings menu, enter:

-   **Privacy Policy URL**  
    [https://datacrazy.io/politica](https://datacrazy.io/politica)
    
-   **Terms of Service URL**  
    [https://datacrazy.io/termos](https://datacrazy.io/termos)
    
-   **User Data Deletion URL**  
    [https://datacrazy.io/politica](https://datacrazy.io/politica)
    

After filling it out:

➡ Click on **Save**  
➡ Then on **Publish**  
➡ App Status: **OK / Active**

* * *

## Step 3 – Create System User

1.  Go to **System Users**
    
2.  Create a user with:
    
    -   **Type:** ADMIN
        
    -   **Name:** Tracking
        

### Assign the App to the user

1.  Select the user you created
    
2.  Click the **three dots (…)**
    
3.  Choose **Assign assets**
    
4.  Select **APP**
    
5.  Assign the App created earlier with:
    
    -   ✅ **Permission: Full control**
        

* * *

## Step 4 – Generate System Token

1.  With the **Tracking** user selected
    
2.  Click on **Generate Token**
    
3.  Select the created **App**
    
4.  Set the **expiration:** NEVER
    

### Required permissions on the token

Check the following permissions:

-   `ads_read`
    
-   `whatsapp_business_management`
    
-   `whatsapp_business_messaging`
    
-   `whatsapp_business_manage_events` _(requires active use case)_
    
-   `read_insights` _(requires active use case)_
    

➡ Generate and save the token safely.

⚠ **Important notice:** The token **is only displayed once** at the time of generation. If you **close the window/modal without saving**, it **cannot be viewed again**.

If this happens, you'll need to **generate a new token** (it doesn't cause technical issues, just rework). So, **save the token immediately in a safe place**.

* * *

## Step 5 – Identify the WABA ID

The **WABA ID** is the ID of your WhatsApp Business account and will be used in API calls.

### How to find the WABA ID

1.  Go to **Connections** in the Datacrazy CRM
    
2.  Click on your **WhatsApp** connection
    
3.  Go to **Manage / Update connection**
    
4.  Find the field **WhatsApp Business ID (WABA ID)**
    

📷 **Image #1 – WABA ID location**  
The image below highlights exactly where the **WABA ID** can be found on the connection configuration screen.

> This is the value that must be used in the API calls in the next steps.
> 
> **Image #1**
> 
> ![](https://staticfiles.gleap.io/gattachments/9Uf5UnJhcP4NO1ZC4HOjkxCNx3RdM8p17ZsbwQhmmZH3zCPenSmFqOUWqedG6YKGETP4uyM7NUe.png)

* * *

## Step 6 – Query or create Dataset via API

For this step, we’ll use **ReqBin** to test the API:

🌐 [https://reqbin.com/](https://reqbin.com/)

### Endpoint

[https://graph.facebook.com/v16.0/\_WABA\_ID\_/dataset?access\_token=\_SEU\_TOKEN\_](https://graph.facebook.com/v16.0/_WABA_ID_/dataset?access_token=_SEU_TOKEN_)

🔁 Replace:

-   `_WABA_ID_` with the WABA ID of your account
    
-   `_SEU_TOKEN_` with the token generated in the previous step
    

* * *

### Step 6.1 – Query Dataset (GET)

-   **Method:** GET
    
-   **URL:** endpoint above
    

#### Expected result

-   ✅ If it **returns data** → dataset already exists
    
-   ⚠ If it **returns empty** → you'll need to create it
    

* * *

### Step 6.2 – Create Dataset (POST)

If the GET doesn't return any dataset:

-   **Method:** POST
    
-   **URL:** same endpoint
    
-   **Headers:**
    

Content-Type: application/json

> The body of the request may vary depending on the API. If it’s required, follow the pattern shown in the video/tutorial.

#### Expected result

-   **Status 200 or 201** → Dataset created successfully  
      
    **Image #2**
    
    ![](https://staticfiles.gleap.io/gattachments/kVGozqRv1psHPaYDJ60cM3wGjum5dniYhlm3i9cJUVDweMpclLK5xXLn0zLqcXnle3MvaRu8lWA.png)
    

* * *

## Step 7 – Finishing up

After completing all the steps:

✅ App created and published  
✅ System user configured  
✅ Token generated with correct permissions  
✅ Dataset created or validated

* * *

## Final notes

-   Always follow the order of the steps
    
-   Permissions only appear on the token if the **use case is active**
    
-   Use the support video to validate specific payload details
    

🎥 **Follow the steps in the video** as indicated.

📌 **Flows used:**

### Tracking #1 – Lead Tracking

Responsible for **receiving leads** and **saving the information of the ad** that originated the click.

This flow uses the token generated by the App to:

-   Identify the lead source (campaign, ad set, ad)
    
-   Associate the lead with the correct ad
    

Persist this data in the Datacrazy CRM

##   
🔗 Flow Link #1:  
[https://drive.google.com/file/d/1-ZomxV6V44HQly1Rmk4CHM1\_aoVGoOSl/view?usp=drive\_link,](https://drive.google.com/file/d/1kaDplV_DEpW11OirAmihOGdthiBKHWZh/view?usp=drive_link)  

* * *

### Tracking #2 – Purchase Event Sending (WhatsApp Pixel)

Responsible for **sending purchase (won) events** to the **WhatsApp Business Pixel**.

This flow allows you to:

-   Report conversions to Meta
    
-   Improve ad optimization and learning
    
-   Close the tracking loop between ad → lead → purchase
    

##   
🔗 Flow Link #2:

[https://drive.google.com/file/d/1WMvmW2ELcJHM0Y9-Wdp177ERqEOf13nh/view?usp=drive\_link](https://drive.google.com/file/d/1WMvmW2ELcJHM0Y9-Wdp177ERqEOf13nh/view?usp=drive_link)

## Tracking #3 -- (SHA256) sends events without identifiers, feeds Meta with low impact and rarely generates attribution.

Explanation for those who use flow #3 when CTWA\_ID/FBCLID is missing

## 🔗 Flow #3 link

[https://drive.google.com/file/d/1hx3CAVhoVdSYA2TmGVAxS6xHwncLJsLE/view?usp=drive\_link](https://drive.google.com/file/d/1hx3CAVhoVdSYA2TmGVAxS6xHwncLJsLE/view?usp=drive_link)

* * *

## 📌 What it is

Used when there is NOT:

-   `ctwa_id`
    
-   `fbclid` / `fbc`
    

Tracking done via:

-   Phone (SHA256)
    
-   CAPI / Offline Events
    
-   Meta Pixel
    

* * *

## ⚙ How it works

Meta tries to:

1.  Identify the user via data (e.g. phone)
    
2.  Match with ad clicks
    

👉 Without a strong identifier, the match is weak

* * *

## ⚠ Limitations

Situation

Result

<table data-id="92fa0fb0-2bb0-4f58-b8b3-102872a2e8d4" style="min-width: 50px;"><colgroup><col style="min-width: 25px;"><col style="min-width: 25px;"></colgroup><tbody><tr><td colspan="1" rowspan="1"><p data-id="ff216756-3d83-44b8-bbf0-6e6829634fc9">Only phone (hash)</p></td><td colspan="1" rowspan="1"><p data-id="67f41558-8e8d-48c5-90fa-483090d053f6">Weak match</p></td></tr><tr><td colspan="1" rowspan="1"><p data-id="a5476bc5-bcc2-46a9-9e12-459f1b509b76">No identifier</p></td><td colspan="1" rowspan="1"><p data-id="6f44497c-c3bc-4189-a208-724d2a7a713d">No attribution</p></td></tr><tr><td colspan="1" rowspan="1"><p data-id="3c549d8d-c846-47a1-8719-04409c490fa3">Multiple clicks</p></td><td colspan="1" rowspan="1"><p data-id="06dac6e7-616f-4c05-acef-cad03af9d983">Loses trust</p></td></tr><tr><td colspan="1" rowspan="1"><p data-id="32a1145a-518f-4598-ba6b-8863e416b1c5">Different phones</p></td><td colspan="1" rowspan="1"><p data-id="2e8d06a2-3f1c-4b8d-b4c8-08e45a03e120">Match failure</p></td></tr></tbody></table>

* * *

## 📉 Real impact

-   ❌ Doesn’t show up in campaigns (in most cases)
    
-   ⚠ Weak optimization
    
-   ⚠ Low-quality signal
    
-   ✅ Still feeds the algorithm (a little)
    

* * *

## 🧠 Rule of thumb

Only attribute if there is:

-   Strong user match
    

-   clear and unique click
    

* * *

## 📊 Quality

Type

Quality

<table data-id="d03efa31-c61b-4bbc-87b8-30b9a7d56482" style="min-width: 50px;"><colgroup><col style="min-width: 25px;"><col style="min-width: 25px;"></colgroup><tbody><tr><td colspan="1" rowspan="1"><p data-id="06461748-da71-404d-bd7b-664c800bdc63">Pixel + fbclid / CTWA_ID</p></td><td colspan="1" rowspan="1"><p data-id="bd3d8fca-5c96-4028-bd99-35f0a7e06a25">High</p></td></tr><tr><td colspan="1" rowspan="1"><p data-id="5deedc40-9080-431e-ae4e-e87c1a61f292">CAPI with fbc/fbp</p></td><td colspan="1" rowspan="1"><p data-id="f520fee5-4dca-4ae2-b39b-1b0634af797f">Medium-high</p></td></tr><tr><td colspan="1" rowspan="1"><p data-id="f46d359b-b551-4761-9885-01acb9d034ca">Flow #3 (SHA256)</p></td><td colspan="1" rowspan="1"><p data-id="f29766ad-0453-4b14-bfb9-b4d29875137e">Low</p></td></tr></tbody></table>

* * *

## 🚀 Recommendation

-   Keep sending it (better than nothing)
    
-   Classify as `LOW_QUALITY`
    
-   Don’t use as the main metric
    
-   Prioritize capturing:
    
    -   `ctwa_id`
        
    -   `fbclid`
        
    -   `ref`
        

* * *

## ✅ Conclusion

-   Feeds Meta → **YES**
    
-   Optimizes campaigns → **A little**
    
-   Generates attribution → **Rarely**
    

> Complementary, doesn’t replace proper tracking.
