Guides
Conversions API
Create conversion rules, associate them with campaigns, capture the click's li_fat_id, send server events and see matching and attribution.
The Conversions API takes conversions from your server or CRM (a sale, a qualified lead) and attributes them to the campaigns the member saw or clicked. There are three resources: rules (/rest/conversions), the association of rules with campaigns (/rest/campaignConversions) and events (/rest/conversionEvents). Scope rw_conversions and a role on the account other than VIEWER.
1. Create the rule
curl -s 'https://linkedin-ads.mimicr.dev/rest/conversions?autoAssociationType=OBJECTIVE_BASED' \
--header 'Authorization: Bearer <token>' --header 'LinkedIn-Version: 202610' --header 'X-Restli-Protocol-Version: 2.0.0' \
--header 'Content-Type: application/json' \
--data '{
"account": "urn:li:sponsoredAccount:521119150",
"name": "Lead qualificado no CRM",
"conversionMethod": "CONVERSIONS_API",
"type": "LEAD",
"postClickAttributionWindowSize": 30,
"viewThroughAttributionWindowSize": 7
}'{
"id": 752612,
"account": "urn:li:sponsoredAccount:521119150",
"name": "Lead qualificado no CRM",
"type": "LEAD",
"conversionMethod": "CONVERSIONS_API",
"enabled": true,
"postClickAttributionWindowSize": 30,
"viewThroughAttributionWindowSize": 7,
"attributionType": "LAST_TOUCH_BY_CAMPAIGN",
"valueType": "DYNAMIC",
"associatedCampaigns": [ { "campaign": "urn:li:sponsoredCampaign:347365458", "conversion": "urn:lla:llaPartnerConversion:752612", "associatedAt": 1793949811328 } ],
"campaigns": ["urn:li:sponsoredCampaign:347365458"]
}Unlike the other creates, this one returns the rule in the body (the id also comes in x-restli-id). The rule URN is urn:lla:llaPartnerConversion:752612.
| Field | Rule |
|---|---|
type | One of the 34 types (LEAD, PURCHASE, QUALIFIED_LEAD, SIGN_UP…); MARKETING_QUALIFIED_LEAD and SALES_QUALIFIED_LEAD since 202608 |
postClickAttributionWindowSize | 1, 7, 30 or 90 days (default 30); 180 and 365 only for the long-window types (PURCHASE, LEAD, QUALIFIED_LEAD…). Otherwise: 400 "365 is not an available post-click window selection. Available: [1, 7, 28, 30, 90]" |
viewThroughAttributionWindowSize | The same set, default 7 |
attributionType | LAST_TOUCH_BY_CAMPAIGN (default: each associated campaign gets credit) or LAST_TOUCH_BY_CONVERSION (only the most recent) |
valueType | DYNAMIC (the event value), FIXED (the rule's value) or NO_VALUE |
autoAssociationType=ALL_CAMPAIGNS associates up to 200 ACTIVE, PAUSED or DRAFT campaigns; OBJECTIVE_BASED follows LinkedIn's objective mapping. Rules aren't deleted (DELETE answers 501): disable them with {"patch": {"$set": {"enabled": false}}}.
2. Associate campaigns
Only associated campaigns get attribution. To associate one by hand:
curl -si 'https://linkedin-ads.mimicr.dev/rest/campaignConversions/(campaign:urn%3Ali%3AsponsoredCampaign%3A347373377,conversion:urn%3Alla%3AllaPartnerConversion%3A752612)' \
--request PUT \
--header 'Authorization: Bearer <token>' --header 'LinkedIn-Version: 202610' --header 'X-Restli-Protocol-Version: 2.0.0' \
--header 'Content-Type: application/json' \
--data '{ "campaign": "urn:li:sponsoredCampaign:347373377", "conversion": "urn:lla:llaPartnerConversion:752612" }'
# 204The campaign and the rule must belong to the same account. Campaigns with optimizationTargetType MAX_CONVERSION only activate with an associated rule (CONVERSION_CAMPAIGN_MISSING_ASSOCIATED_CONVERSION).
3. Capture the click's li_fat_id
When the member clicks the ad, the landing page gets li_fat_id in the URL (with the Insight Tag in enhanced mode, the default). Store that value with the lead or the order. In Mimicr, the click is the ad.click action:
npx mimicr action linkedin-ads ad.click creative=urn:li:sponsoredCreative:166531097
{ "ok": true, "action": "ad.click", "message": "Clique registrado: li_fat_id e653420e-9356-47c1-b935-f0c850887959.", "data": { "landingUrl": "https://www.example.com.br/?li_fat_id=e653420e-9356-47c1-b935-f0c850887959", "liFatId": "e653420e-9356-47c1-b935-f0c850887959", "member": "yLp4Ms3J8-", "clickUrl": "https://linkedin-ads.mimicr.dev/mimicr/click/…" } }Open clickUrl in the browser to follow the redirect to your landing page, as a member would (ad click).
4. Send the event
curl -si https://linkedin-ads.mimicr.dev/rest/conversionEvents \
--header 'Authorization: Bearer <token>' --header 'LinkedIn-Version: 202610' --header 'X-Restli-Protocol-Version: 2.0.0' \
--header 'Content-Type: application/json' \
--data '{
"conversion": "urn:lla:llaPartnerConversion:752612",
"conversionHappenedAt": 1793950473457,
"conversionValue": { "currencyCode": "BRL", "amount": "1200.00" },
"eventId": "pedido-1001",
"user": {
"userIds": [
{ "idType": "LINKEDIN_FIRST_PARTY_ADS_TRACKING_UUID", "idValue": "e653420e-9356-47c1-b935-f0c850887959" },
{ "idType": "SHA256_EMAIL", "idValue": "5e884898da28047151d0e56f8dc6292773603d0d6aabbdd62a11ef721d1542d8" }
]
}
}'
# 201, empty bodyFor several events, send {"elements": [...]} with X-RestLi-Method: BATCH_CREATE (up to 5,000). The batch is all-or-nothing: one invalid event fails them all, and the message points at the batchIndex.
| Identifier | Format |
|---|---|
SHA256_EMAIL | Lowercase hex SHA-256 of the trimmed, lowercased email |
LINKEDIN_FIRST_PARTY_ADS_TRACKING_UUID | The click's li_fat_id |
user.lead | urn:li:leadGenFormResponse:… of a lead (the typical CRM case with Lead Sync) |
user.externalIds | Your ids of the member; only the first is used |
user.userInfo | firstName and lastName together (or, since 202609, hashedFirstName and hashedLastName), plus companyName, title, countryCode |
ACXIOM_ID, PLAINTEXT_IP_ADDRESS, SHA256_IP_ADDRESS, GOOGLE_AID | Accepted; in Mimicr they never match on their own |
user.userIds is required: send [] when you identify only by lead, externalIds or userInfo.
Errors
| Case | Response |
|---|---|
No conversionHappenedAt | 422 ERROR :: /conversionHappenedAt :: field is required but not found and has no default value |
No user.userIds | 422 ERROR :: /user/userIds :: field is required but not found and has no default value |
A lead that isn't a URN | 422 ERROR :: /user/lead :: Invalid Urn format. Invalid prefix. |
| More than 90 days ago, or in the future | 400 Validation failed because [{field=Invalid Conversion time, batchIndex=0, type=INVALID_CONVERSION_TIME_FIELD_VALUE, message=Conversion time should be within 90 days.}] |
| No usable identifier | 400 … type=INVALID_USER_IDENTIFICATION_FIELD_VALUE … |
| Malformed hash (64 lowercase hex) | 400 … type=INVALID_FIELD_VALUE … |
| Disabled rule | 400 "… Conversion enabled should be true" |
| Rule of another account, or member without a role | 403 USER_NOT_AUTHORIZED |
Matching and attribution in Mimicr
LinkedIn returns no match result. Mimicr tries to match each event to a member, in this order: the li_fat_id of a stored click, an existing lead, the hashed email of a sandbox member (personas, lead submitters, member.create), an externalId already linked to a member, and the name. Then it attributes:
- Post-click: a click by the member on a creative of an associated campaign, within the post-click window before
conversionHappenedAt. - Post-view: the matched member counts as having seen the account's campaigns that were serving within the window.
- The same
(conversion, eventId)within 7 days counts once.
Attributed conversions go into adAnalytics (externalWebsiteConversions, conversionValueInLocalCurrency and the CONVERSION pivot), after conversionLagMinutes (default 0). Each event's outcome (matched, unmatched, attributed) shows in the console and in:
curl --url 'https://api.mimicr.dev/v1/linkedin-ads/objects?kind=conversion_event' \ --header 'Authorization: Bearer mk_...'
To force outcomes: capi.set_outcome outcome=matched count=3 (the next 3 match the admin) or outcome=unmatched; capi.link_external_id links an externalId to a member; an eventId starting with rejeitar- refuses the batch and with nomatch- never matches.