Conversion Tracking for Websites
Overview
Conversion tracking enables you to measure your return on ad spend by tracking the actions people take after viewing or engaging with your ads on X. Your conversion events will allow you to report on the performance of your campaigns but can also be used to help better optimize and target your ads.
Conversion Tracking Solutions
There are two solutions to choose from:
X Pixel - This is a website tag that is implemented on your website to track site actions or conversions.
Conversion API - This is a direct, server-to-server integration that allows you to share data without the need for a website code implementation.
Both solutions achieve the same goal and have largely the same functionality: enabling conversion tracking for your web campaigns. It is critical to implement at least one of these options in order to unlock the full capabilities of web campaigns.
Choosing the Right Solution:
For most advertisers, we recommend using the X Pixel. If you are just getting started, the X Pixel can be the most straightforward solution to get set up.
If you have key considerations with regards to your website (example: unable to implement JavaScript on your website), then the Conversion API may be the best option.
X Pixel
The X Pixel is made up of two parts:
- Base code - This should be implemented across all pages of your site. The base code tracks visits to a website and initializes the pixel so that you can track additional events via event code or create audiences using Audience Manager.
- Event code - This requires the base code to be implemented. The event code allows you to track individual actions on your website, like an add-to-cart button or purchase.
Implementation: You have two options to implement the X Pixel - via direct integration or via a supported 3rd party Tag Manager.
Setting up the X Pixel requires:
Generating the X Pixel and creating events to track
Implementing the base code across your website
Implementing event code in key locations on your website (example: when a user makes a purchase)
For a step-by-step video on how to generate the X Pixel within Ads Manager, please see below.
Generating the Pixel and Creating Events
1. Log into your ads account at ads.X.com
2. Under “Tools,” select “Events Manager”
- Not seeing a Tools tab in your account? This is likely because a credit card hasn’t been added to your account. Find how to add one here.

3. Click on “Add event source” and read/select “I agree” to the X terms of use
- If you have created the X Pixel before for your ads account, you’ll be able to see it in the pane on the left side of Events Manager. If this has already been created, you can skip to step 6.
4. You are now in the “Install pixel code” page. Here you can see the actual code that needs to be placed on the website and the option to “Allow 1st-party cookies."
(i) The “Allow 1st-party cookies” check box enables our Click ID functionality to leverage first-party cookies on websites. Specifically, this enables measurement of conversion events beyond landing page visits. This first party cookie will store the Click ID parameter appended to your landing page URL in order to measure the conversion events that take place on your website.
This option is required to access the full functionality of Conversion Optimization and Dynamic Product Ad solutions, as the data would be used for campaign optimization. Read more about Click ID here and about how we leverage cookies here.
Note that this option is default on. It can be turned off by de-selecting the “Allow 1st-party cookies” option. This option is also accessible via the “Settings” tab if you previously created a pixel.

5. Click the “Save event source” button to save your new pixel. You will be brought to the “Events Manager” main screen.
6. Next, you’ll need to create events to track actions across your website. Which actions to track may vary, depending on your goals. For example: an e-commerce company may want to implement “Add-to-Cart” and “Purchase” events while an advertiser tracking email sign-ups may want to implement “Lead.”
- Read more about available conversion events and parameters here.
7. Click the “Add events” button.
8. On the “Event Details” screen, enter a name for the event. From the Type dropdown, choose the type of action you would like to track. You can also adjust your attribution window and toggle on “Website activity audience” if you so choose. Click “Next.”

9. On the “Setup method” screen, you will be able to choose how you want to define your event. We recommend defining your event with code as this will provide you the most flexibility. For example, it allows you to send key information back via event parameters. Select “Define event with code” and click “Next.”
10. In the “Event installation” screen, you can see three tabs at the top, which allow you to access the instructions for your preferred installation approach. More details on the Tag Manager installation are provided here and more details on Conversion API can be found here.
When choosing to install the pixel code in your website code, you’ll be able to use the checkboxes to create a template of your event code pixel. Select the event parameters that you wish to use and the template pixel code will dynamically change below. Hit “Save” to save your newly created event.

Note: the parameter check boxes only serve to create a template of your event code. Checking the boxes will not automatically measure these event parameters. The code will need to be updated to dynamically pass values for the event parameters. More detail is provided in the implementation details below.
11. Repeat steps 7 to 10 to create events for all the relevant actions you would like to track.
- In almost all cases, a particular conversion type (i.e. Purchase or Download) should only be used once on your website. Creating several conversion events of the same conversion type leads to bifurcating of signal and will lead to an inefficient optimization setup.
- Advertisers defining event code implementation for Dynamic Product Ads campaigns are required to select the following parameters:
- Contents (choose this for all events)
- Value (choose for Purchase event, it denotes purchase value)
- Currency (choose for Purchase event, it denotes purchase currency)
- Email (choose this for all events)
After completing the above, you will need to implement your newly created pixel base code and event code in order to start tracking actions.
Implementing the X Pixel
You can choose to implement the X Pixel base code and event code either by:
Direct: by downloading and integrating the code provided on a website.
Tag Manager: by leveraging an approved 3rd party Tag Manager.
This section walks through direct implementation. If you plan to integrate your base code and/or event code via a Tag Manager, check out the Tag Manager section here.
Base Code Implementation
1. In “Events Manager,” near the top of the page, click on “View Twitter pixel” for the pixel you would like to implement.

2. In the “Install pixel code” page, make sure the “Install with Pixel code” tab is selected.
3. From here, copy or download the pixel code in the “Pixel code” field.
4. Paste this code before the HTML tag of all pages on your website. (Implementing across your website is critical to properly track actions across your website.)
- Once you implement the base code, we will auto-create “Site Visit” and “Landing Page View” events that measure a visit to a website or a view of the ad landing page, respectively. These can be found in “Events Manager.” Read more about these events in the FAQ section.
Event Code Implementation
1. In “Events Manager,” find the event you would like to implement.
2. Click on the three (3) dots next to the event name and select “Edit event.”

3. Click “Next” twice to go to the “Event installation” screen.
4. Click on “Download code snippet” under the “Code” field.
5. Add this code to specific elements of your website (like a thank you page or “download” button).
- If you are using event parameters, update default values when you install the code on your website.
6. Repeat steps 1-5 for each event you would like to track.
Implementing Pixel Code of Multiple Accounts on the Same Page
If you are using more than one ads account for marketing your website, you may end up needing to add multiple base codes and event codes to the same page. For example, you have two accounts with pixel_id1 and pixel_id2 respectively, and you want to track an event for each account on a page with event id tw-pixel_id1-event_id1 and tw-pixel_id2-event_id2, respectively.
You can bundle the pixel code together as follows:
twq('event', 'tw-pixel_id1-event_id1', {
value: 200.00,
currency: 'USD',
conversion_id: ‘1234abcd’,
contents:
[
{content_id: 'OT001', content_name: ‘bird seed’, content_price: 50, num_items: 1},
{content_id: 'OT002', content_name: ‘bird cage, content_price: 150, num_items: 1}
]
});
Event Parameters
Event parameters give details into the conversion action - e.g. what the product was. Certain parameters can also be used to improve measurement.
Parameters, with the right events, can even be used to gain an understanding of the ROI of your website campaigns, including the total revenue or total conversion value your campaign generated, and the total number of items purchased.
To record how much someone is spending or the amount they’re buying, you need to install the proper event (like Purchase) and pass values to event parameters in your event code.
This table provides an overview of all available parameters you can use for your events. Note, these event parameters can only be used for events defined with code and not for events using URL rules.
Event parameter
Description
Data type
Event parameter
value
Description
Total value of the conversion event (ex: $ value of the transaction in case of a purchase, etc.) |
Data type
Integer or float |
Event parameter
currency
Description
ISO 4217 code (e.g. USD, JPY, EUR) |
Data type
String
Event parameter
conversion_id |
Description
Unique identifier for the event that can be used for deduplication purposes |
Data type
String
Event parameter
search_string |
Description
Text that was searched for on your website |
Data type
String
Event parameter
description |
Description
A string description for additional info |
Data type
String
Event parameter
twclid
Description
X click ID that can be included with any request. The X Pixel already automatically passes twclid from URL or first-party cookie. This parameter can be optionally used to force attribution to a certain ad click. |
Data type
String
Event parameter
status
Description
Status of the sign up or subscription, could be “started” or “completed” |
Data type
String
Event parameter
contents
Description
Array of JSON Objects representing multiple products/content
See below for sub-parameters that can be included in the array.
Data type
Array of Objects
Sub-parameters
Event parameter
Description
Data type
Event parameter
content_type |
Description
Category of the product purchased (Google product taxonomy) |
Data type
String
Event parameter
content_id |
Description
For product catalog users: please pass SKU For all other users: Please pass Global Trade Item Number (GTIN) if available, otherwise pass SKU |
Data type
String
Event parameter
content_name |
Description
Name of a product or service |
Data type
String
Event parameter
content_price |
Description
Price of a product or service |
Data type
Integer or float |
Event parameter
num_items |
Description
Number of products purchased |
Data type
Integer |
Event parameter
content_group_id |
Description
ID associated with a group of product variants |
Data type
String
An example code snippet for a Purchase event could look like this:
Create an ad
Did someone say … cookies?
X and its partners use cookies to provide you with a better, safer and
faster service and to support our business. Some cookies are necessary to use
our services, improve our services, and make sure they work properly.
Show more about your choices.