Skip to content
🚀 Find us on Product Hunt

X (Twitter) Pixel Tracking Setup for WordPress

Quick answer: Use the free container builder wizard to select X (Twitter) Pixel and your events, enter your tracking ID, then import the generated file into Google Tag Manager - no manual tag setup needed for any of the 21 events below.

X Pixel base code and standard events, generated as Custom HTML. This platform does not have a native GTM tag type, so the container wraps its base code in a Custom HTML tag.

Build my X (Twitter) Pixel container →

Events you can track

conversion events

engagement events

By Humayun Kabir Naim — Last updated: 9 November 2026

Quick answer

To track WordPress leads in X through Google Tag Manager, create the pixel in X Ads Manager (Tools → Events Manager → Add event source), install its base code once on every page through GTM — the base pixel automatically reports Site Visit and Landing Page View, nothing to configure — and then create each conversion as an event inside Events Manager: choose a type (Lead covers form enquiries), and X gives that event its own event ID. Back in GTM, one event tag per conversion fires twq('event', 'tw-<PIXEL_ID>-<EVENT_ID>', …) — and the trigger is the whole ballgame: fire it on the form's success signal (the same bridge events and success messages your GA4 and Meta setups already use), never on the submit click. Install the base pixel exactly once: pasting the code into a plugin or theme and building it in GTM — or adding X's own GTM partner integration on top of a hand-built container — doubles every event. Test with the X Pixel Helper before you publish.

X Events Manager showing the pixel and its Pixel ID

What gets tracked

X's model differs from Meta's: there is no universal list of named events your tag calls by name. You define each event in Events Manager, it gets an ID, and your tags fire IDs. On a WordPress lead site the working set looks like this:

WordPress actionX event (created in Events Manager)Fired by
Any page viewSite Visit / Landing Page View (automatic)Base pixel — no setup
Contact or quote form submittedLead-type eventSuccess signal → form_submission
Contact Form 7 submissionLead-type eventBridge tag on wpcf7mailsent → cf7_form_submission
WPForms / Gravity Forms submissionLead-type eventBridge tag on the plugin's success event
Calendly booking completedCustom event (or Lead type)postMessage bridge → calendly_booking
User registration completedLead-type or Custom eventdataLayer push on registration success
Newsletter signupLead-type eventForm success signal
Lead-magnet file downloadCustom eventClick trigger or dataLayer push
Phone, WhatsApp or email clickCustom eventGTM Click triggers — intent only

Three consequences of the ID model are worth internalising. The tag knows nothing but IDs: an event tag with a mistyped or stale event ID fires into the void — X has no "unrecognised event name" warning, because names were never the mechanism. Parameters ride along per event: value and currency when the lead has a meaningful value, and a conversion_id as a unique key per conversion (essential if the Conversions API ever joins — see below). Click rows stay intent: as on every other platform in this series, a WhatsApp click is not a lead, and X's bidding will believe whatever your triggers tell it.

Deep dives: Form Submission, Contact Form 7 Submission, Calendly Booking. The same success signals feed WordPress + Meta and WordPress + LinkedIn. See all options on the WordPress hub.

Before you start

  1. An X ads account with the pixel created. Ads Manager → Tools → Events Manager → Add event source. Note the Pixel ID (the event source's ID; in this hub's examples, the dummy o1234). If the Tools menu is missing, X usually wants a payment card on the ads account first.
  2. Your events created in Events Manager before you open GTM. One per conversion (Lead for the enquiry form, a Custom event for downloads), each with its own event ID — the GTM tags below are built from these IDs, so creating events afterwards means rebuilding tags.
  3. GTM installed on the site — once, and only one X route. X offers three install paths: pasted base code, its GTM partner integration, and a hand-built GTM container. Pick one. The partner integration and a manual container in the same account install the same base pixel twice.
  4. Forms with a provable success moment. Thank-you redirect, visible success message, or the form plugin's success event — the identical requirement as the GA4/Meta/LinkedIn hubs. If any of those setups already works on this site, your signals already exist.
Creating a Lead event in X Events Manager and getting its event ID

Route 1: Use the free TagManagerBuilder container

Open the GTM Container Builder, choose WordPress, then X (Twitter) Pixel, and tick the events you want. Enter your Pixel ID and the event IDs from Events Manager where the wizard asks, download the JSON, then in GTM go to Admin → Import Container and choose Merge → Overwrite conflicting tags, triggers, and variables. The container includes the bridge tags for CF7, WPForms, Gravity Forms and HubSpot forms, so those submissions are detected without extra code. Do not also run X's partner integration into the same container. Test with the testing section below before publishing.

Route 2: Build it manually in GTM

Step 1 — The base pixel tag

Tags → New, choose the Twitter Pixel template from the Community Template Gallery (or a Custom HTML tag with the base code from Events Manager), enter your Pixel ID, and set the trigger to All Pages. The template's initialisation is the twq('config', 'o1234') call with your ID in place of the dummy. From the first publish, every page reports Site Visit and Landing Page View automatically. If a base tag already exists in the container — from an earlier attempt or the partner integration — keep one and delete the other before going further.

X Pixel base tag in GTM with the Pixel ID on All Pages X's GTM partner integration and a manual container — the double-install trap

Step 2 — One event tag per conversion, by event ID

For each event you created in Events Manager, build one event tag (the template's event type, or a Custom HTML tag) that fires that event's ID. In raw form the call is:

<script>
  twq('event', 'tw-o1234-a1b2c', {
    conversion_id: 'lead-1728123456789'
  });
</script>

Both IDs in that first argument are dummies standing in for yours: tw- + your Pixel ID + - + the event's own ID, exactly as Events Manager's install code shows it. Copy it from there rather than typing it — this string is the event's whole identity. Add value and currency parameters only when the conversion genuinely has a value. The conversion_id is a unique key for that specific conversion (here, generated once at submission); the pixel works without it, but it is the parameter X uses to recognise a duplicate if the same conversion later also arrives through the Conversions API, so generating it once at the source costs nothing and future-proofs the setup.

X event tag in GTM firing the event by its composite event ID

Step 3 — Trigger on success, never on the click

Attach each event tag to the signal that proves the action completed, first match wins:

  1. The plugin's success event. The container's bridge tags already convert CF7, WPForms, Gravity Forms and HubSpot submissions into dataLayer events (cf7_form_submission and siblings) — attach the event tag with a Custom Event trigger on the matching push. A generate_lead push from your GA4 setup serves identically.
  2. Success message. An Element Visibility trigger on the form's success message, once per page.
  3. Thank-you page. A Page View trigger limited to the confirmation page's path.

The click-based version of this setup — event tag on the submit button, or on GTM's generic Form Submission trigger — counts every validation failure, double-tap and bot poke as a Lead. On X, where a smaller advertiser's conversion volume is already thin, a click-fired Lead doesn't just inflate a report; it teaches the delivery system to find people who click forms and abandon them. Success-firing is the entire quality control this platform gives you, not optional polish.

Why X events belong on form success, not on the submit click, shown in GTM Preview

Test it: GTM Preview and the X Pixel Helper

GTM Preview showing the X Lead tag fired on success, not on the click
  1. Click Preview in GTM and open your site in Tag Assistant. Confirm the base tag fires once on every page, and that no second base tag (template or partner-integration) fires beside it.
  2. Submit each form once with test details — including one deliberately invalid submission, which must produce no X event tag.
  3. In the Preview timeline, confirm the event tag fires on the success signal (cf7_form_submission, the visibility event, or the thank-you page view) with the correct composite event ID visible in the tag.
  4. Install the X Pixel Helper extension and repeat the flow on the live page. It shows the pixel and the events X actually received, with their parameters — this is the check that catches a wrong event ID, because Preview only proves GTM fired something.
  5. In Events Manager, check the pixel's activity: the base events should show as receiving, and your test Lead should register against the event you created. Allow X some processing time before declaring a healthy helper result a failure.
  6. Only then click Submit in GTM to publish.
X Pixel Helper confirming the base pixel and Lead event on the page The Lead event receiving data in X Events Manager

The server-side question, answered honestly

X does have a Conversions API — a server-to-server route for sending the same conversions without the browser — and Events Manager offers it alongside the pixel, including through the GTM partner integration (client side, server side, or both). For most WordPress sites it is still the wrong project: the integration effort is real, typical WordPress lead volume is small, and a correctly success-fired pixel loses far less data than a click-fired pixel plus an API ever recovers. If you do adopt it later, the deduplication rule is the one honest sentence in this space: send the same conversion_id in the pixel event and the API event for the same conversion, and X can recognise the pair as one. Generate that ID once, at the submission, and let both channels read it — two systems inventing their own IDs is, on every platform in this series, how duplicates are born. Until then: pixel only, installed once, fired on success.

WordPress-specific troubleshooting

Pixel Helper shows the base pixel, but my event never appears. Work the ID chain: the tag's composite ID must be tw-<your Pixel ID>-<that event's ID>, copied from the event's install code in Events Manager — an event created under a different pixel, or an ID typed from memory, fails silently. Then check the trigger: a tag waiting on a success signal that never fires (wrong form plugin event, a message selector that doesn't match) looks identical to a bad ID in the helper. Preview separates the two in one test submission.

Every event appears twice. Two base pixels. The usual pairings on WordPress: base code pasted into a header/footer or pixel plugin and the GTM tag; or X's GTM partner integration enabled and a hand-built container in the same account. The pixel's loader should arrive through exactly one route. Remove the duplicate at its source, not by pausing tags at random.

Leads in X far exceed actual enquiries. The event tag is on the click. Move it to a success signal as in Step 3, then re-test with a deliberately invalid submission: it must produce nothing. Until that test passes, treat every Lead number X shows you as fiction and don't let campaigns optimise toward it.

Events fire in Preview but nothing reaches Events Manager. Preview proves the tag fired in your draft workspace — publish the container and retest live. Then suspect consent and blockers: an ad-blocked test browser is the classic false alarm (test in a clean profile), and if your consent setup holds the base tag until acceptance, events behave accordingly.

Site Visit shows, but Landing Page View (or the reverse) is missing in reports. Both are automatic products of the same base pixel; a partial pair usually means the base tag fires late or conditionally on some templates (a landing-page template missing GTM, or the tag scoped to a consent trigger those pages skip). Check the base tag's trigger coverage across templates rather than rebuilding events.

My event IDs changed after I recreated an event. Recreating an event in Events Manager mints a new ID, and every GTM tag carrying the old one is now firing a dead ID. Update the tag, and treat event deletion/recreation in Events Manager as a change that always has a GTM half.

Next steps once this is clean: WordPress + LinkedIn and WordPress + Meta run the same form signals for the other B2B/social channels, and Consent Mode v2 keeps the pixel's consent behaviour consistent with the rest of the container.

Frequently asked questions

Why does my X event tag need two IDs?

Because X separates the source from the event. The Pixel ID identifies your event source (the pixel) and goes into the base tag's twq('config', …) call; each conversion you create in Events Manager then gets its own event ID, and event tags fire the combination — tw-<Pixel ID>-<event ID>. A tag carrying only the Pixel ID reports page-level activity, not your conversion; a tag with the wrong event ID fires an event X doesn't know, silently.

Can't I just fire the Lead event when someone clicks submit?

You can, and it will inflate everything it touches. A click happens before validation: failed submissions, accidental taps and abandoned forms all count. Fire on the success signal instead — the form plugin's success event, its success message, or a thank-you page — so X's numbers track real enquiries and its optimisation learns from people who actually enquired.

I set up the pixel through X's GTM partner integration. Should I also import the container?

No. The partner integration installs X's base pixel (and, optionally, dataLayer-driven events) into your GTM account itself. Adding a hand-built or generated container on top installs the same base pixel a second time, and every page view and event doubles. Choose one route: the integration for a light setup, or a container you control for the full success-signal build in this hub.

Does X offer server-side tracking like Meta's Conversions API?

Yes — X has a Conversions API, and Events Manager offers it next to the pixel, including a server-side option in the GTM partner integration. Most WordPress sites don't need it: a success-fired pixel at typical lead volumes loses little, and the API is a project of its own. If you adopt it, pass the same conversion_id in the pixel and API copies of each conversion — that shared key is how X recognises them as one event rather than two.

Pixel Helper sees my base pixel but not my Lead event. What's wrong?

Most often the event ID or the trigger. Verify the tag's ID matches the event's install code in Events Manager character for character (tw-<Pixel ID>-<event ID>), then submit the form in GTM Preview: if the tag never fires, the trigger's success signal isn't happening (wrong plugin event or message selector); if it fires in Preview but not live, publish the container and retest in a browser without an ad blocker.

Do I need to set up Site Visit and Landing Page View events in GTM?

No. Both are automatic consequences of the base pixel: install it once on every page and X creates and populates them by itself. Your GTM work starts at the first real conversion — the Lead, booking or download events you define in Events Manager and fire by ID on their success signals.

Share with