# Osoul deep-dive: ad signals, CAPI and Meta audiences

Source: https://www.alouaniyoussef.com/projects/osoul-ad-signals

- Kind: founder
- Status: live
- Company: Osoul
- Updated: 2026-11-27

One signal service deduplicates, matches and masks QR scans, orders, reservations, the waitlist and visits, and a sync engine decides which of them reach Meta.

Part of the [Osoul platform](/projects/osoul) case study. The transport underneath, signed events and the Go tracking service, is in [server-side tracking and CAPI sync](/projects/osoul-server-side-tracking). This page is about what happens to those events once they arrive: how each one is cleaned, deduplicated, matched to a guest and masked, how an engine decides which events are worth sending, how they reach Meta exactly once, and how one Meta app manages ads data for every restaurant.

## Problem

A restaurant's conversions are spread over a whole evening and several systems. A guest sees an ad, scans the QR code at the table, orders twice, pays at the POS and comes back a month later with a reservation made by phone. On a busy night someone else joins the waitlist, leaves, and books online the next day.

Each of these steps is a signal Meta can learn from, but they arrive from different apps, at different times, sometimes more than once and sometimes out of order. Sent as they come, Meta counts the same reservation twice, never sees the visit, and receives personal data it should not have. Sent carefully, it learns which ads bring guests who actually come and spend.

## Constraints

- **Each conversion counts once**, whatever the channel, retries, replays or late corrections.
- **Most guests are anonymous**: a QR scan carries no name, phone or email, only what the browser exposes.
- **Consent decides what leaves**: identifiers are sent only for guests who agreed to ad signals, in restaurants that enabled them, and only hashed.
- **Outcomes arrive late**: a ticket closes hours after the booking, and a cancellation can arrive after the booking was already sent.
- **One integration, many restaurants**: each restaurant keeps its own ad account, dataset and audiences, and Osoul manages them through a single Meta app without ever mixing tenants.

## Architecture

```mermaid
flowchart TB
  qr[QR scans · table sessions] --> intake
  orders[Orders] --> intake
  resa[Reservations · app, bot, phone] --> intake
  wait[Waitlist] --> intake
  visits[Visits · POS ticket] --> intake
  subgraph svc[Signal service]
    intake[Verify and pre-process] --> dedup[Dedup · idempotency and timing]
    dedup --> norm[Normalise]
    norm --> match[Identity match · guest record]
    match --> mask[Mask · hash, drop free text]
    mask --> engine{Sync engine · sync or skip, with a reason}
  end
  engine -->|selected| app[One Osoul Meta app · per-restaurant access]
  engine -->|skipped| internal[(Osoul analytics only)]
  app --> capi[Conversions API · restaurant dataset]
  app --> lists[Customer-list audiences · reservations, customers]
  app --> anon[Dataset audience · anonymous guests]
```

### One service for every signal

Every app sends its events to the same signal service instead of talking to Meta directly. That is the only place where an event can be compared with the ones before it, so it is the only place where deduplication, identity and consent can be decided correctly.

| Source | What it carries | Identity available | What Meta can receive, if selected |
| --- | --- | --- | --- |
| QR scan | Table, session, `fbclid` from the ad click | Anonymous: `fbp`, `fbc`, IP, user agent | `ViewContent`, and membership of the anonymous-guests audience |
| Order | Items and amounts within a table session | Same as the session | Nothing on its own: orders are folded into the visit |
| Reservation | Party size, time, channel (app, bot, phone) | Phone, email, guest record | `Schedule`, and membership of the reservations audience |
| Waitlist | Queue entry and its outcome | Phone, guest record | `Lead` when the guest joins |
| Visit | Seated session closed with a POS ticket | Guest record when known | `Purchase` with value, and membership of the customers audience |

### The pipeline, stage by stage

1. **Pre-processing.** Each event's signature is verified, its payload is validated against the shared tracking schema, and it is stamped with the tenant and the time it happened, separate from the time it arrived. Invalid events are rejected with a reason instead of being silently dropped.
2. **Deduplication.** Before any work is done, the event's idempotency key is checked; duplicates stop here. This stage is covered in detail below.
3. **Processing.** Events are turned into business facts. Orders accumulate on their table session; a closed session with a POS ticket becomes one visit; a waitlist entry that gets seated is linked to that visit; a reservation edited three times stays one reservation.
4. **Normalisation.** Identifiers are brought to the exact form Meta matches against: phone numbers to E.164 digits with the country code (a Moroccan `06…` becomes `2126…`), emails trimmed and lowercased, names stripped of accents and spaces, currencies and amounts in a single format.
5. **Identity matching.** The event is attached to a guest record using deterministic keys only: a normalised phone or email from a reservation or waitlist entry, or the table session that links a QR scan to the order and the visit. The guest record's id becomes the `external_id` Meta sees, so the same guest has the same id in every event.
6. **Masking.** Everything that may leave the platform is reduced to what Meta needs. Identifiers are hashed with SHA-256 after normalisation; names, raw phone numbers and free-text fields such as reservation notes, which can hold allergies or other health details, are dropped. Guests without ad consent keep only the anonymous browser identifiers.
7. **Sync decision.** A processed event is not automatically sent. The sync engine decides, event by event, whether it goes to Meta, to an audience, to both or nowhere, and records why.
8. **Delivery.** Selected Conversions API events are batched per restaurant dataset, and audience changes are queued per audience. Both go out through the same Meta app with that restaurant's access.

### Deciding what Meta should see

Not every event helps Meta. It optimises on whatever it receives, so noise is not harmless: a stream of low-value or unmatchable events teaches it to find more people like them. The sync engine exists to send fewer, better signals.

For each processed event it answers a few questions in order:

- **Is this event type enabled for this restaurant?** Each restaurant chooses which signals feed its ads, for example bookings and visits but not waitlist entries.
- **Does it describe a real guest outcome?** Staff test bookings, internal and complimentary tickets, and events from demo tables are never sent.
- **Is it worth learning from?** A QR scan with no ad click behind it, or a zero-value ticket, adds volume without teaching Meta anything about guests who spend.
- **Can Meta match it?** Events without enough identifiers to reach a useful match quality are kept for Osoul's own analytics instead of being sent.
- **Is it still in time?** Events about to fall outside Meta's accepted window are dropped rather than sent with a wrong time.
- **Is the guest allowed in?** Consent and the restaurant's settings decide whether identifiers are attached and whether the guest may enter an audience.

Every decision is stored with its reason, synced or skipped and why. That makes the engine auditable: when a restaurant asks why a booking did not show up in Events Manager, the answer is a record, not a guess. It also makes rule changes safe to reason about, since the effect of a new rule can be measured on past decisions before it is switched on.

### Deduplication: idempotency, timing and platform ids

Duplicates come from everywhere: a mobile app retrying on a flaky connection, a bot and a staff member creating the same booking, a POS sending the same ticket twice, a worker crashing after sending but before recording it. One mechanism is not enough, so there are three layers.

- **Idempotency.** Every event carries a key derived from its source record and event type, for example the reservation id and `Schedule`. The service records each key once per tenant; a second arrival with the same key is acknowledged and discarded. Delivery to Meta is recorded the same way, so a retry after a crash does not send twice.
- **Timing.** Some duplicates do not share a key, so time does the rest. Repeated QR scans on the same table session within a short window count as one. Reservation edits are coalesced so Meta sees the booking, not every change to it. A visit is held until its POS ticket closes, so a table that orders three times produces one `Purchase` with the final value, sent with the time the ticket closed.
- **Platform ids.** Every Conversions API event carries a deterministic `event_id`. Where the browser pixel fires the same event, it uses the same id, so Meta's own deduplication on `event_name` + `event_id` within 48 hours removes the overlap.

Out-of-order events are handled by state, not arrival order: a cancellation that arrives before its booking is kept until the booking appears, and the pair produces no `Schedule`. A cancellation after the `Schedule` was sent cannot be retracted from Meta, so the guest is removed from the reservations audience on the next sync and no `Purchase` ever follows.

### Three audiences per restaurant

Through the Meta app, Osoul creates three audiences in each restaurant's own ad account and keeps them in sync:

- **Reservations.** Guests who booked, through any channel. A customer-list Custom Audience built from hashed phone numbers and emails. Used for retargeting guests who booked but have not visited recently, and as an exclusion so acquisition campaigns do not pay for guests who already have a table.
- **Customers.** Guests with a closed ticket, with the ticket value attached. A customer-list audience that seeds value-based lookalikes, so Meta looks for people like the guests who spend, not just the ones who book.
- **Anonymous guests.** Guests who scanned a QR code but never gave an identifier. They cannot go in a customer list, so this is a dataset audience built by Meta from the `ViewContent` events and their browser identifiers, with no personal data uploaded at all.

How Meta handles them shapes how they are synced:

- **Matching is blind.** Meta matches uploaded hashes against its users and keeps only the matches. Osoul only ever sees an approximate audience size, never who matched, so match quality is measured on events through Event Match Quality, not on lists.
- **Lists are diffs, not uploads.** Additions and removals are sent in batches of up to 10,000 hashed rows. A full rebuild uses Meta's replace session, so the audience is never empty while it is being rewritten.
- **Thresholds.** A lookalike needs at least 100 matched people in a country, so a new restaurant's customers audience is synced from day one but only used as a seed once it is large enough.
- **Advantage+ audience.** Meta treats these audiences as suggestions and may deliver beyond them. Location, minimum age and excluded audiences remain hard limits, which is why the exclusions matter as much as the seeds.
- **Consent withdrawal** removes the guest from every list on the next sync, and their future events stop carrying identifiers.

### One Meta app for every restaurant

Osoul uses a single Meta app to access and manage ads data on behalf of its customers. Each restaurant connects once from the Osoul Portal and grants the app access to its ad account and dataset; from then on Osoul can send events, create the three audiences and keep them in sync without anyone sharing a password or copying a pixel id by hand.

- **Permissions.** Managing ads on behalf of other businesses needs `ads_management` and `business_management` with advanced access, which Meta grants only after App Review and business verification. The app asks for nothing beyond what sending events and managing audiences requires.
- **Tokens per tenant.** Each restaurant's access token is stored encrypted with the tenant and used only by that tenant's workers, so a bug in one restaurant's job cannot write into another restaurant's account.
- **Rate limits.** Marketing API limits apply per ad account, so queues are per restaurant: one restaurant's backlog never delays another's audiences.
- **Revocation.** A restaurant can remove access from its Business Manager at any time. The service detects the authorisation error, stops sending, keeps the events, and asks the restaurant in the Portal to reconnect.

## Key decisions

1. **One signal service instead of one integration per app.** Deduplication, identity and consent can only be decided where all events meet. Apps send events; only the service talks to Meta.
2. **Select, don't forward.** Syncing everything is the easy default and the wrong one: Meta learns from noise as readily as from signal. A dedicated engine decides what is synced, per restaurant and per event, and records why.
3. **Idempotency first, Meta's window last.** Meta's 48-hour deduplication only covers pixel and server overlap. Keys recorded by the service are what stop retries, replays and crashes from ever producing a second conversion.
4. **Send the visit, not the orders.** Sending each order as a purchase would count one table several times. Waiting for the ticket to close costs a few hours of latency and gives Meta one purchase with the real value.
5. **Deterministic identity only.** Guests are matched on exact normalised phone, email or table session, never on guesses. A wrong merge would send one guest's history under another guest's id.
6. **Mask before delivery, not in it.** The delivery workers receive hashed identifiers only, so a logging mistake there cannot leak a phone number, and nothing from reservation notes can reach Meta.
7. **One app, isolated per restaurant.** A single reviewed Meta app keeps onboarding to one click, while per-tenant tokens, queues and audiences keep restaurants as isolated in Meta as they are in Osoul's databases.

### What made it hard

- **Two clocks.** Every event has the time it happened and the time it arrived, and they can be hours apart. Meta accepts website events up to 7 days old and in-store events up to 62 days, so the service sends the real event time and alerts on anything about to fall outside those limits.
- **Phone numbers.** Guests type numbers in local, international and WhatsApp formats. Before normalisation, the same guest produced different hashes and matched nobody; country-aware normalisation was the largest single gain in match quality.
- **Anonymous to known.** A QR scan becomes useful only when it can be linked to a later booking. The table session is the bridge: its browser identifiers are stored with it, so when the same guest books, the visit carries both the `fbp` and the guest's `external_id`.
- **Cancellations and no-shows.** Meta has no way to undo a conversion. The fix is in what is sent and when: bookings are coalesced before sending, and value is only ever reported on a closed ticket.
- **Sensitive data.** Restaurant data is full of free text: allergies, celebrations, notes about guests. Masking by allow-list, sending only known fields, was the only safe default; a block-list would always miss something.
- **Testing against a live platform.** Each restaurant's dataset is tested with Meta's test event codes before going live, so new event mappings can be checked in Events Manager without polluting real data.

### Journify: integration analysis

[Journify](https://www.journify.io/) sells this layer as a product, under the same name: "ad signal infrastructure for Meta, TikTok, Snap, and Google". Its public pages describe a server-side pipeline (capture, validate, enrich, activate, learn), Conversions API destinations for Meta web, mobile and offline events, Meta Custom Audiences, and other platforms including TikTok, Snap, Google, Amazon, LinkedIn and Pinterest. They claim hashing before data leaves the customer's environment, consent enforcement, deduplication and identity resolution, and they focus on the GCC market. Journify was evaluated, not integrated. This analysis is based on its public pages, not its private documentation.

**What it would add.** TikTok and Snap matter a lot for restaurant ads in Saudi Arabia and the wider GCC, and each has its own Conversions API with its own event names and rules. Journify would cover those platforms without Osoul building a sender for each.

**What its public pages do not answer:** how it builds event ids and deduplicates, which decides whether it can coexist with Osoul's idempotency keys; whether each restaurant gets its own workspace, dataset and audiences; anything about reservations, waitlists or table sessions; audience sync mechanics; and pricing.

**Integration options:**

1. **Osoul as a source, Journify as the fan-out.** The signal service keeps deduplication, identity and masking, and forwards finished, hashed events to Journify with its own ids. Journify delivers them to TikTok, Snap and Google. Meta stays on Osoul's own app, so the most important pipeline keeps its guarantees.
2. **Journify for everything, including Meta.** The least code, but deduplication, consent and tenant isolation move to a vendor whose mechanics are not public, and the restaurant's Meta access moves from Osoul's app to Journify's.
3. **Stay in-house.** Full control, at the cost of a sender per platform.

If the platform mix grows beyond Meta, option 1 is the recommendation, with one rule: each platform has exactly one sender. If Meta events ever went through both paths, they must carry the same `event_id`, or Meta would count each one twice.

## Results

Numbers to come.

## Stack and links

Event-driven, Data pipelines (ETL), Data privacy and retention
