The Twitter Conversion API allows you to send information from your server directly to Twitter servers, which can be used to measure campaign success.
With Twitter CAPI, you make tracking more secure and accurate. Like Facebook, Twitter allows and recommends using a hybrid method of tracking, web+server. When combining web and server tracking, deduplication is required. To match users in events to Twitter profiles, they use customer data: email and twclid.
This guide will discuss how the Twitter conversion API works and how to set up the Twitter CAPI tag in sGTM.
You need more than just a Twitter pixel ID or API token to identify your Twitter CAPI. Twitter requires additional authentication, which is impossible to implement via sGTM. That is why, for now, the Twitter CAPI tag works only with the stape. Feel free to modify the tag template and implement authentication yourself if needed.
The new Twitter CAPI is not ready for prime time yet and will require 5x more work than “standard” CAPI implementation if you're already familiar with FB or TikTok's APIs. In addition, there are some other complications when using their platform that make things difficult.
You will need a dev account, apply for access to Twitter CAPI, and generate several access tokens. We will elaborate on all these steps later in a blog post.
To access the Ads API, contact a Twitter representative.
Existing Ads API Applications
If you have an active Ads API application, you can use it and its access tokens for the Conversion API.
Access Tokens
- A command line with web authorization (twurl)
- A command line with PIN-based authorization
- Custom web flow
Tokens for the Conversion API must be from users with AD_MANAGER or ACCOUNT_ADMIN access, which you can check via the authenticated_user_access endpoint.
Note: You can share tokens with users without AD_MANAGER or ACCOUNT_ADMIN access.
These two keys can be generated only if you have a Twitter developer account. To receive a Twitter dev account, you must apply for one and wait 1-3 days for your application to be approved.
When applying, you need to request Essential Access. Make sure to use the correct Twitter account to apply for dev accounts since it is impossible to change accounts later.
Create an App using the Project and App section when you receive a dev account. Once you have done this, a Consumer Key and Consumer Secret will be generated.
You can find these two in your ad on your Twitter dev account.
Important: Twitter CAPI tag works only if you use Stape hosting for sGTM containers.
2. Send data from web to server GTM. You can use GA4, Webhooks, or Data Tag/Data Client.
3. Download the Twitter Conversion API tag from the Template Gallery.
4. Create a new tag and select Twitter Tag.
5. Add Consumer Key, Consumer Secret, OAuth Token, OAuth Token Secret. I’ve described how to generate these values here.
6. Add Twitter pixel ID and Event ID. You can find these values in the Tweeter Events Manager.
7. Add the Server Event Data Override and User data you want to send to Twitter, and set up a trigger.
Twitter CAPI tag parameters:
Consumer Key, Consumer Secret, OAuth Token, OAuth Token Secret - you can find it in your Twitter dev account after you’ve created a Twitter app. We will show you how to generate these later.
Pixel ID - This is your Twitter ad account's Universal Website Tag (UWT) ID. To find it, go to the Twitter events manager.
Event ID - When creating a conversion API event in the Twitter events manager, you will find it.
Use HttpOnly cookies - Forbids JavaScript from accessing the cookie if enabled.
Server Event Data Override - select to override one of the standard server parameters: conversion time, number of items, currency, value, conversion ID, description, and contents.
User Data - add user data: email or twclid.
Logs Settings - select if you want to use Stape logs.
9. Testing events. When your event has successfully received conversion events within 12 to 24 hours the status of the ‘Single event web tag’ should show TRACKING upon the Conversion Tracking page of the Ads Manager. It will not impact in-flight campaigns that send conversions via the Conversion API.
Twitter supports event deduplication. Combining web and server tracking requires sending a deduplication key with both web and server events. Use conversion_id to send the deduplication key. Deduplication happens only if events were received within 48 hours.
To create a server-only event, use the Twitter events manager to create a new event and select Install with Conversion API on the third step.
Unlike other platforms, Twitter accepts only user email and twclid. When you send an email, it should be hashed with SHA256. Twitter tag automatically hashed user email.
Unfortunately, there is no way to test Twitter server events in real time. If tracking is set up correctly, you should see the status of the ‘Single event web tag’ show tracking upon the Conversion Tracking in the Ads Manager within 12 to 24 hours.
Twitter CAPI can be a great addition to your server-side tracking stack. Though the authorization process for Twitter CAPI is incredibly complicated for now, other logic works highly similar to FB or TikTok conversion APIs: You can send custom or standard events and use web+server or server tracking only. Twitter asks for user data to match users, but for now, they support only user email and twclid.
Twitter CAPI has two main downsides: the authentication process and the lack of a real-time testing tool. Because of the verification process, the Twitter tag only works with stape servers for sGTM. If Twitter simplifies the authentication process, the stape team will update the tag to work with GCP.
This guide will help you familiarize yourself with Twitter CAPI and set it up in sGTM. For more detailed information about Twitter CAPI, check the official documentation.
All it takes is a few simple questions. Click Get A Quote, fill-up the form, and we will send you a quote.