_referral object into memory with the source ad’s data.
With that information you can attribute the lead, route by campaign, personalize the first reply, or log the source in your CRM—without manually reconciling data between Meta Ads Manager and the conversational channel.
How it works
When a user clicks a Click to WhatsApp ad, WhatsApp opens with a starter message and Meta attaches the ad’s referral data to that first interaction. Jelou detects that data and automatically inserts it into the conversation’s memory under the_referral variable.
No Marketplace installation is required. The
_referral object is injected automatically whenever the conversation originates from a Click to WhatsApp ad.Detecting whether a chat comes from an ad
To know if a conversation arrived from a Meta ad, check whether the_referral variable exists in memory. When the conversation originates from an ad, Jelou inserts the following object:
_referral does not exist in memory, the conversation did not originate from a Click to WhatsApp ad (for example, a user messaging the number directly).
Learn more about how to read these variables in: Memory.
Field reference
| Field | Description |
|---|---|
source_url | Short URL of the source ad (for example, an fb.me link). |
source_id | Identifier of the source ad or post in Meta. |
source_type | Source type. The value ad indicates the conversation came from an ad. |
body | Main ad copy the user saw before clicking. |
media_type | Ad content type: image or video. |
video_url | URL of the ad video. Present when media_type is video. |
thumbnail_url | URL of the ad content’s thumbnail. |
ctwa_clid | Click to WhatsApp Click ID: unique identifier for the click, useful for attribution and reporting. |
welcome_message.text | Welcome message configured in the ad, which starts the conversation. |
Available fields depend on the ad. An image ad won’t include
video_url, and some fields may arrive empty depending on how the creative is configured.Using it in your flow
Inside any node you can access the ad data with the memory syntax{{$memory._referral.field}}. For example:
{{$memory._referral.source_type}}→ad{{$memory._referral.ctwa_clid}}→ click identifier for attribution{{$memory._referral.body}}→ the ad copy the user saw
Check whether the conversation comes from an ad
At the start of the flow, evaluate whether
_referral exists in memory. If it does, the conversation arrived from a Click to WhatsApp ad.Save the attribution for reuse
Keep
ctwa_clid and source_id in memory or send them to your CRM to attribute the lead to the source campaign.Related articles
Memory
How to read and persist variables across conversations and nodes.
Google Ads
Attribute WhatsApp conversations to your Google Ads campaigns.