How to Implement Twitter (X) Pixel/Web Tracking via Google Tag Manager

If you would like to implement Twitter Pixel/Web tracking via GTM, follow these easy steps to publish.


Step 1: Download the Pre-Built Twitter Tags

In your Elevar App, navigate to Pre-Built Tags

Search for Twitter > Click into the Twitter Container

Add in your Universal Tag ID [How to find this?] > Select Download Container

Step 2: Import the Pre-Built Twitter Tags into GTM Web

Log in to your Google Tag Manager Account > Select your GTM Web Container

Select Admin > Import Container

Select to import the file that you just downloaded in Step 1. Choose a New Workspace and title it Twitter. Then choose Merge > Overwrite. Your import will look similar to the below:

Select _Confirm _to import the tags

Step 3: Configure Your Events

Twitter gives you two options for conversion tracking:

  • URL-Based Events
  • Single Event Website Tags

URL-Based Events

If you're going to use the URL-Based Events, then you only need to have the "Twitter - Base Pixel" tag in Google Tag Manager. You can delete the Purchase and Add To Cart tag.

hen in Twitter's Event Manager, select Add events.

Configure your event. For example, if you're configuring a purchase event, it may look like the following:

Once you save your event, it will appear in the Events section of your Universal Website Tag. Add as many URL-based events as you need.

Single Event Website Tags (Twitter Recommended)

Twitter also gives you the option to use Single Event Website Tags. This can be helpful for events like Add to Cart where a URL rule might not apply.

To create a new Single Event Website Tag, select Add Event Source in Events Manager:

Choose Single Event Website Tag

Agree to Twitter's Terms of Use.

Configure your event details. For example, if you are creating an Add to Cart event, it may look like the below:

You'll be shown an event code. You can grab your unique event ID in this code:

You'll also see this Event appear in your Events Manager with the Tag ID

Put this Tag ID in your Event Specific GTM Tag. For example, since I made an Add to Cart Event, I'm going to put the Tag ID in the variable UPDATE Add to Cart Event ID.

Step 4: [Optional] QA Your Tags

QA the new tags with Google Tag Manager's Preview Mode

Step 5: Publish the Pre-Built Tags

In your Twitter Tracking workspace, select Submit

Select Publish

Step 6: Remove Previous Twitter Tracking

Remove any previous Twitter Tracking. This could be a hardcoded script in your Shopify Theme or Checkout Settings, a third party app, or other GTM tags.