Conversion Event Tracking
This guide is for AI assistants helping RaffleX tenants add third-party conversion tracking (TikTok, Google Ads, etc.) to their site. All code goes in Settings > Advanced > Header Code, which injects into the <head> of every page.
RaffleX exposes JavaScript hooks for two commerce events: AddToCart and Purchase. The sections below explain how to listen for each event and fire the appropriate tracking call for each platform.
Prerequisites
The ad platform's base pixel or tag must be installed in Header Code before any event tracking will work.
Facebook: No action needed. RaffleX automatically installs the Facebook Pixel and fires all events (including AddToCart and Purchase) via both browser pixel and server-side Conversions API. Do not add duplicate
fbqcalls or events will double-count. For more on the built in Meta integration, see Facebook and Meta tracking.TikTok: The TikTok base pixel script must be added to Header Code, including the
ttq.install('YOUR_PIXEL_ID')call. Get the pixel code from TikTok Ads Manager > Events > Website Pixel > Manage.Google Ads: The
gtag.jsscript must be loaded in Header Code with the Google Ads conversion ID (e.g.,AW-XXXXXXXXX). Get the tag from Google Ads > Goals > Conversions > the specific conversion action. If you also want general visitor analytics, see Google Analytics and UTM tags.
AddToCart
Fires when a user adds tickets to their cart from a product page. Does not fire for upsell additions.
Hook
Livewire.on('addtobasket', (event) => {
// Your tracking code here
});Available Data
event.productId
number
The product/competition ID
event.productPrice
number
Price per ticket
event.tickets
number
Number of tickets added (quantity)
event.content
string
Product title
event.fbEventId
string
Facebook event ID for deduplication
TikTok
Replace 'GBP' with the tenant's currency code (e.g., 'USD', 'EUR'). Currency must be uppercase.
Google Ads
Replace 'GBP' with the tenant's currency code.
Facebook (Reference Only)
RaffleX already fires this event automatically via both browser pixel and server-side CAPI. The code below is for reference only. Do not add this to Header Code or it will cause duplicate events.
Purchase
Fires once per order on the thank you page. RaffleX pushes a purchase event to window.dataLayer containing full order data. Since Header Code loads in <head> before the body scripts, it can intercept this push.
Hook
The pattern below overrides dataLayer.push to intercept the purchase event. Place this in Header Code and it will automatically catch the event when it fires on the thank you page.
Available Data
data.transaction_id
string
The order ID
data.value
number
Order total
data.currency
string
Currency code (e.g., "GBP")
data.items
array
Order items
data.items[].item_name
string
Product title
data.items[].item_id
number
Product ID
data.items[].quantity
number
Number of tickets
data.items[].price
number
Price per ticket
TikTok
Note: TikTok uses CompletePayment as the event name for purchases, not Purchase.
Google Ads
If Google Ads conversion tracking is set up via gtag.js, RaffleX already fires gtag('event', 'purchase', ...) on the thank you page. No additional code is needed unless you want to fire a specific conversion action.
To fire a specific Google Ads conversion action:
Replace AW-XXXXXXXXX/CONVERSION_LABEL with the tenant's Google Ads conversion ID and label.
Facebook (Reference Only)
RaffleX already fires this event automatically via both browser pixel and server-side CAPI with full deduplication. The code below is for reference only. Do not add this to Header Code.
Important Notes
Facebook is automatic. RaffleX handles all Facebook Pixel events (PageView, ViewContent, AddToCart, InitiateCheckout, Purchase, CompleteRegistration) through both browser pixel and server-side Conversions API. Adding your own
fbqcalls will result in duplicate events and inflated reporting.Currency codes are always uppercase (e.g.,
GBP,USD,EUR). Match the currency configured in the tenant's settings.AddToCart only fires for direct cart additions, not upsell items added from the cart drawer.
Purchase fires once per order. RaffleX uses a cache guard to prevent the event from firing on page refreshes or revisits to the thank you page.
dataLayer interception must be set up in Header Code (which loads in
<head>) so the override is in place before the thank you page body scripts execute.
Last updated