Connecting Craft CMS to X Ads
Craft is a developer-oriented CMS, usually built bespoke by an agency, which means the implementation is whatever that agency decided and nothing is standard. X is a conversation platform where a large share of engagement is discussion rather than intent, which makes the gap between engagement metrics and conversions unusually wide. The join between them succeeds or fails on one thing: whether the twclid click identifier reaches the Craft Commerce order before the conversion happens, because X Ads can only match a conversion it can tie back to a click it recognizes.
Free30 minutesNo obligation
Specific to this pair
Craft Commerce and X Ads: hold twclid on the cart, not the cookie
Capture twclid from the landing URL by script and write it to a custom field on the Craft Commerce cart, which becomes the order. Send the purchase to the X Conversions API from PHP with twclid, hashed email, value, currency and the order reference as conversion ID, matching any pixel purchase, and reconcile orders individually at first.
X traffic mostly opens in the in-app browser, where the X pixel's storage is short-lived. On a Craft store, the dependable place for twclid is the cart: capture it from the landing URL by script, since static caching may hide the query string from PHP, and write it to a custom field on the Commerce cart. Because that cart becomes the completed order, the value is waiting when the order-complete listener runs. A shopper who switches from the in-app browser to Safari arrives with neither the cart nor twclid, and nothing recovers that, so measure how often it happens rather than guessing.
Send the purchase to the X Conversions API from PHP with twclid, the hashed order email, value and currency, and the order reference as the conversion ID. If the confirmation template also fires the X pixel purchase, it must carry the same order reference. X volumes for a single Craft store are often small, so a doubled count can pass for a strong week.
With that few orders, reconcile X-attributed orders against Commerce one by one for the first weeks rather than trusting totals. If X is mostly a brand channel for the business behind the Craft site, a server pipeline is more than it needs.
Craft → X Ads · what breaks
Why this join usually fails — Craft → X Ads
- 01
The twclid click identifier never reaches Craft
Craft's template caching and static caching plugins both serve stored output, and because every build is custom, where the capture code lives differs per site. There is no standard place to look.
- 02
Every install is bespoke
There is no standard Craft setup, so an approach that worked on another Craft site may have nothing to attach to on this one. Read the build before quoting.
- 03
Engagement mistaken for intent
A post can be quoted, argued with and shared widely by people with no interest in buying anything. Optimising toward engagement on this platform reliably finds an audience that will never convert, and the engagement numbers look excellent throughout.
- 04
Nothing reconciles afterwards
Read the delivered and matched counts in X's reporting rather than assuming a 200 response means the event was usable.
Craft → X Ads · the fix
What working looks like — Craft → X Ads
The twclid click identifier on every order
Conversions arriving in X Ads
The conversion is matched to a click or an engagement and becomes available for optimisation and reporting.
Reconciled against the source
Craft CMS's own records are the reference, not either dashboard.
Craft → X Ads · architecture
How Craft and X Ads actually connect
- 1
Craft CMS holds the truth
Craft installs are bespoke by nature. Establish how this particular build models a completed order before assuming anything transfers from another Craft site.
- 2
X Ads needs a click to match
An event X recognises, a conversion identifier for deduplication, hashed customer information, and the click identifier where you have it.
- 3
The identifier is the bridge
The twclid click identifier, captured at the visit and carried into the Craft Commerce order.
- 4
The event source decides reliability
Fire from the event listener in PHP rather than a Twig template, which may be cached.
- 5
Deduplication at the destination
X deduplicates browser and server events on a shared conversion ID. Send both without pairing them and every conversion counts twice — worth testing deliberately, because X volumes are often small enough that a doubling reads as a good week.
Craft → X Ads · normal or broken
Working vs. broken, side by side — Craft → X Ads
Normal, not a fault
The twclid click identifier present on the order
Visible on the record itself in Craft CMS, not merely captured somewhere on the site.
Sent from the Craft Commerce order-complete event
Deduplicated correctly
X deduplicates browser and server events on a shared conversion ID. Send both without pairing them and every conversion counts twice — worth testing deliberately, because X volumes are often small enough that a doubling reads as a good week.
Reconciles with the source
X Ads's count and Craft CMS's records agree within a few percent over a closed window.
Actually broken
The twclid click identifier missing on most records
Craft's template caching and static caching plugins both serve stored output, and because every build is custom, where the capture code lives differs per site. There is no standard place to look.
Sent from the browser
There is no standard Craft setup, so an approach that worked on another Craft site may have nothing to attach to on this one. Read the build before quoting.
Counted twice, or not at all
A post can be quoted, argued with and shared widely by people with no interest in buying anything. Optimising toward engagement on this platform reliably finds an audience that will never convert, and the engagement numbers look excellent throughout.
Nobody has reconciled it
The dashboard shows a number and no one has compared it to Craft CMS.
Craft → X Ads · diagnose
Diagnostic order — Craft → X Ads
- 01
Count orders carrying the twclid click identifier
- 02
Follow one real conversion end to end
- 03
Read how this specific build handles order completion
Assumptions carried from another Craft project are the main source of wasted time here.
- 04
Compare engagement rate against conversion rate by campaign
On X the two frequently move in opposite directions, and that divergence is the finding rather than a measurement fault.
- 05
Read the match rate, not the success message
Read the delivered and matched counts in X's reporting rather than assuming a 200 response means the event was usable.
Craft → X Ads · prove
How it gets proven — Craft → X Ads
Against Craft CMS's own records, not against either platform's dashboard.
Source of truth
Craft Commerce's order records in your own database, filtered to completed.
- The twclid click identifier confirmed present on a live order.
- Conversions reconciled per order against imported figures, with deduplication verified on a live test.
- Order custom field confirmed populated on an order placed as an anonymous visitor through cache.
Craft → X Ads · free audit
What we check in the free audit
- Count orders carrying the twclid click identifier
- Follow one real conversion end to end
- Read how this specific build handles order completion
- Compare engagement rate against conversion rate by campaign
- Read the match rate, not the success message
Checked against
Craft Commerce's order records in your own database, filtered to completed.
Free30 minutesNo obligation
Craft → X Ads · when not to buy
When you don't need this — Craft → X Ads
- If X Ads already reports conversions that reconcile against Craft CMS's records within a few percent, this join is working and there is nothing to buy.
- Measure identifier coverage yourself first — pull your last hundred orders and count how many carry the twclid click identifier.
- If the original agency is still engaged, the fastest path is usually specifying the field and having them add the hook.
- If X is a brand and community channel for you rather than a performance one, measure it that way and do not force a conversion pipeline onto it.
Craft → X Ads · what we deliver
What gets built — Craft → X Ads
Identifier capture into Craft
Capture the identifier and store it as a custom field on the order through a Craft event listener, server-side.
Event source: the Craft Commerce order-complete event
Fire from the event listener in PHP rather than a Twig template, which may be cached.
Dispatch to X Ads
The X Conversions API, posted server-side with the click identifier and hashed customer data.
Reversals where they exist
Refunds and cancelled orders are recorded against the order.
Written guarantee
95%+ tracking accuracy
Measured against Craft Commerce's order records in your own database, filtered to completed.. Miss it and we keep working at no cost.
From $400 · See packages
FAQ
Craft → X Ads questions, answered
Check the Craft Plugin Store, but don't count on one. The X pixel in templates plus a server event from a Commerce order listener is the usual setup.
Many X clicks open in the in-app browser and never reach checkout in that session, and twclid is lost if the shopper switches browsers. Storing twclid on the cart keeps what can be kept.
Almost always because the twclid click identifier never reached the Craft Commerce order. Craft's template caching and static caching plugins both serve stored output, and because every build is custom, where the capture code lives differs per site. There is no standard place to look. Measure coverage before debugging the dispatch.
X appends twclid to the landing URL and the pixel stores it. It behaves like other click identifiers, with the usual caveat that a large share of X traffic arrives through the in-app browser, where storage is partitioned and short-lived.
The Craft Commerce order-complete event. Fire from the event listener in PHP rather than a Twig template, which may be cached.
Read the delivered and matched counts in X's reporting rather than assuming a 200 response means the event was usable.
More on Craft → X Ads
- Craft → Google AdsConnecting Craft CMS to Google Ads
- Craft → Microsoft AdsConnecting Craft CMS to Microsoft Ads
- Craft → Apple Search AdsConnecting Craft CMS to Apple Search Ads
RELATED GUIDES
Where Craft → X Ads fits in the rest of your tracking
- X Ads · Local servicesX Ads conversion tracking for local service businesses
- X Ads · B2BX Ads conversion tracking for B2B companies
- X Ads × CRM DealsHow to reconcile X Ads against your CRM's closed-won deals
- X Ads · Comparison page → demoHow to track comparison page visit to demo request for X Ads
- Concrete CMS → X AdsConnecting Concrete CMS to X Ads
- Craft → PinterestConnecting Craft CMS to Pinterest
- Local servicesConversion tracking for local businesses, where most conversions bypass the website
- Ghost → X AdsConnecting Ghost memberships to X Ads
Free · 30 min
Get Craft and X Ads joined properly
Free30 minutesNo obligation
