WASync · Developers

Campaign and ad set on conversations from ads

Give WASync a Meta Ads token and every conversation that starts from a Click-to-WhatsApp ad carries the campaign, the ad set and the ad in the UTM fields of the lead or deal, with their names on the timeline.

When a customer writes to you from a Click-to-WhatsApp ad, WhatsApp tells WASync which ad it was, and nothing more. WASync writes that on the lead or deal: UTM_SOURCE = facebook, UTM_MEDIUM = ctwa, the ad id in UTM Campaign and the click id in UTM Content, plus the UF_CRM_CTWA_* fields.

To report by campaign and ad set you need the two ids Meta does not send with the message. WASync can look them up in your ad account if you give it a token of your own Business Manager. With the token in place the UTM fields follow Meta's own convention:

FieldValue
UTM Campaigncampaign id
UTM Termad set id
UTM Contentad id

The click id stays in UF_CRM_CTWA_CLID, and the timeline note on the record shows the names: Campaign: «Préstamos octubre» (1202…), Ad set: «Profes» (1202…), Ad: «FACSIS IA» 1202….

1. Create a System User token with ads_read

In Meta Business Suite → Business settings:

  1. Users → System users → Add. Name it, for example, Wasync attribution (Meta refuses names with several capital letters); the Employee role is enough.
  2. Open the system user → Assign assets → Ad accounts → tick the ad account that runs your Click-to-WhatsApp ads → give it View performance (read is enough).
  3. Generate token → Meta asks for an app of your own portfolio and lists only the permissions that app has. You need an app with the Marketing API product: pick one you already have, or create one once at developers.facebook.com (Create app → type Business → Add product → Marketing API). Then set the expiry to Never, tick ads_read only, and copy the token. Meta shows it once.

2. Paste it in WASync

Open the WASync app in Bitrix24 → Settings → the card Campaign and ad set on conversations from ads. Paste the token and click Save token. WASync stores it encrypted and never shows it again.

To check it, paste the numeric id of one of your ads (from Ads Manager, the Ad ID column) and click Test: the card shows the campaign, the ad set and the ad that WASync would write.

Save the token once; Test shows what a conversation from that ad would carry.

What changes, and what does not

  • Only new conversations from ads get the three ids; records attributed before the token keep what they have.
  • A record that already has a UTM Source from another channel is never overwritten; the UF_CRM_CTWA_* fields are always written.
  • Each ad is looked up once and remembered for a day, so a campaign with thousands of conversations costs one request to Meta.
  • If Meta refuses the lookup (expired token, an ad from another ad account), the conversation is attributed as before, with the ad id only, and nothing else breaks.
  • Remove the token at any time with Remove token; WASync goes back to writing the ad id only.

Related: CRM records and timeline.

On this page