Analytics Lab / Instrumentation
X Pixel Sandbox
Example X (Twitter) Pixel calls attached to common page elements. The X Pixel does not use event
names in code. Each conversion event is created in X Ads Manager, which assigns it an event ID of the
form tw-<pixel id>-<event id>. The page fires that ID with
twq('event', ...). The console on the right shows each call and its parameters.
Tracking plan
Each element carries a data-twq-event attribute with its event ID and a
data-twq-parameters attribute with its parameters. The event type (Purchase, Lead and
so on) is set on the event in Ads Manager, not in code.
- Start free trial
- Event ID
tw-abc12-trl01 - Type
Start trial - Book a demo
- Event ID
tw-abc12-lde01 - Type
Lead - Internal link
- Event ID
tw-abc12-cus01 - Type
Custom - Video start / 50%
- Event ID
tw-abc12-cus02, tw-abc12-cus03 - Type
Custom - File download
- Event ID
tw-abc12-dwn01 - Type
Download - Add to cart / checkout / purchase
- Event ID
tw-abc12-atc01, tw-abc12-chk01, tw-abc12-pur01 - Type
Add to cart, Checkout initiated, Purchase - Demo request form
- Event ID
tw-abc12-lde02 - Type
Lead - Newsletter sign-up
- Event ID
tw-abc12-sgn01 - Type
Sign up
Interactive elements
Click an element to log its twq('event') call. Supported parameters include
value, currency, contents, conversion_id,
description, email_address and phone_number.
Lead events
Trial starts and demo bookings.
Content and navigation
Links, video progress and downloads, mostly used to build audiences.
Commerce
Add to cart, checkout and purchase. On Purchase, conversion_id carries the order ID
and is used to deduplicate against the Conversions API.
Forms
Demo request and newsletter sign-up. To improve matching, pass email_address or
phone_number. Send them SHA-256 hashed after trimming and lowercasing, or check X's
current documentation on client-side hashing before sending plain values.
X Pixel base code
Place the base code in the document head and call twq('config') with your pixel ID. The
config call also records the page view. Fire conversion events afterwards with
twq('event', 'tw-<pixel id>-<event id>', { ... }).
<script>
!function(e,t,n,s,u,a){
e.twq||(s=e.twq=function(){
s.exe ? s.exe.apply(s, arguments) : s.queue.push(arguments);
}, s.version='1.1', s.queue=[], u=t.createElement(n), u.async=!0,
u.src='https://static.ads-twitter.com/uwt.js', a=t.getElementsByTagName(n)[0],
a.parentNode.insertBefore(u,a));
}(window, document, 'script');
twq('config', 'abc12');
</script>