Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

README.md

X Pixel with HTML

This sample shows how to add the X Pixel to a plain HTML site, with no build step. Each page has the X conversion tracking base code in its <head>, which sends a page view when the page loads. The Buy button on the home page sends a purchase event.

How to use

Replace the placeholders in index.html and about.html:

  • YOUR_PIXEL_ID: your pixel ID from X Ads Events Manager
  • YOUR_PURCHASE_EVENT_ID: the event ID of a purchase event you create in Events Manager. It looks like tw-abc12-def34.

Serve the folder over HTTP. The pixel doesn't run on pages opened from the file system.

npx serve .

Open the site, visit both pages, and click Buy. Check the requests with the X Pixel Helper.

Adding the pixel to your site

Paste the base code before </head> on every page, as in these files. Then add event code wherever a conversion happens, such as a button click or a thank-you page. See the implementation best practices.