Manual Conversion Events with the Reddit Pixel
For easy point-and-click conversion event setup, we recommend using the event setup tool.
Not using the Pixel base code? We suggest looking at our Shopify or Google Tag Manager guides instead.
The Reddit Pixel identifies the conversion event based on the event name and JSON objects in the rdt('track')
function.
You can use the Reddit Pixel to track conversion events based on page actions. The Pixel base code will register a PageVisit
event when it's triggered by default. This event should be placed at the minimum on the campaign's destination URL and any pages you'd like to share conversion events.
This integration requires a little technical skill. If that's not in your wheelhouse, you might want to ask the right technical support person on your team for assistance.
To ensure proper deduplication, don't set up multiples of the same conversion event for the Reddit Pixel. This means you should include all the metadata you need in one event. Misconfigurations can lead to more chances of duplications. Ensure you've correctly set up all the needed signals for accurate deduplication.
Before you start
Set up the Pixel base code to initialize the pixel. This will let you understand what actions redditors take after viewing or clicking your ad on Reddit.
<!-- Reddit Pixel -->
<script>
!function(w,d){if(!w.rdt){var p=w.rdt=function(){p.sendEvent?p.sendEvent.apply(p,arguments):p.callQueue.push(arguments)};p.callQueue=[];var t=d.createElement("script");t.src="https://www.redditstatic.com/ads/pixel.js",t.async=!0;var s=d.getElementsByTagName("script")[0];s.parentNode.insertBefore(t,s)}}(window,document);rdt('init','{{Your Pixel ID}}');rdt('track', 'PageVisit');
</script>
<!-- DO NOT MODIFY UNLESS TO REPLACE A USER IDENTIFIER -->
<!-- End Reddit Pixel -->
Remember to replace {{Your Pixel ID}}
with your Pixel ID, which you can find in the Events Manager.
Learn more about setting up the Pixel base code.
Create a conversion event
You can share a conversion event by adding its call after the init call:
Remember to replace {{Your Pixel ID}}
with your Pixel ID to ensure events are accurately shared from your website. You can find your Pixel ID in the Events Manager.
rdt('init','{{Your ID}}');
const addToCartButton = document.getElementById('addToCart');
addToCartButton.addEventListener('click', () => rdt('track', 'AddToCart'));
Or you can add the call between the <script>
tags on the page where the event should happen:
<script>
// Get the button element for adding to cart
const addToCartButton = document.getElementById('addToCart');
// Add event listener to the button
addToCartButton.addEventListener('click', () => rdt('track', 'AddToCart'));
</script>
You can also customize your event to return customer-match-keys-and-identifiers and event metadata fields:
rdt('track', 'Custom', {
customEventName: 'Promotion Event',
itemCount: 2,
value: 19.99,
currency: 'USD',
conversionId: 'ff8d9819fc0e12bf0d24892e45987e249a28dce836a85cad60e28eaaa8c6d976',
email: 'alice@example.com',
phoneNumber: '+15554441234',
externalId: 'abc123',
idfa: 'EA7583CD-A667-48BC-B806-42ECB2B48606',
aaid: 'cdda802e-fb9c-47ad-9866-0794d394c912'
});
This call can be made either in the base code or between the <script>
tags on the page where the event should happen. We recommend adding these parameters to the init call. If this information isn't known at page load, you can add them to the track call.
Reference
Some events support parameters, which lets you customize the event to fit your needs. See how it works.
Conversion event | Standard code |
---|---|
Page Visit |
|
View Content |
|
Search |
|
Add To Cart |
|
Add To Wishlist |
|
Purchase |
|
Lead |
|
Sign Up |
|
Custom |
Set |
Create a custom conversion event
You can create a custom conversion event by setting EventName
to Custom
and assigning customEventName
to a value that doesn't match our pre-existing events. This free-form and case-sensitive value may use any UTF-8 character and can have up to 64 characters including spaces. For example, Promotion Event
and PromotionEvent
will be considered two distinct events.
You can create as many custom conversion events as you'd like, but only the twenty most recent events will be visible in the Events Manager.
rdt('track', 'Custom', { customEventName: 'Promotion Event' });
Set up customer match keys
Customer match keys are optional but highly recommended. We especially recommend sharing emails to catch cross-device or cross-browser conversions, such as when a user clicks your ad in one browser but completes conversion in a different one.
To finish setting up customer match keys, you'll need to update the Reddit Pixel base code. You can do this by adding the following JSON object to either your init call or to a separate call:
We recommend adding these parameters to the init call. If this information isn't known at page load, you can add them to the track call.
rdt('track', 'PageVisit', {
"aaid": "cdda802e-fb9c-47ad-9866-0794d394c912",
"email": "alice@example.com",
"phoneNumber": "+15554441234",
"externalId": "customer12345",
"idfa": "EA7583CD-A667-48BC-B806-42ECB2B48606"
});
All parameters can be shared unhashed or pre-hashed. If you'd like to pre-hash signals, we recommend using SHA-256 and following our guidance.
Reference
Parameter | Example |
---|---|
aaid (string) | "aaid": "cdda802e-fb9c-47ad-9866-0794d394c912" |
email (string) | "email": "alice@example.com" |
phoneNumber (string) | "phoneNumber": "+15554441234" |
externalId (string) | "externalId": "customer12345" |
idfa (string) | "idfa": "EA7583CD-A667-48BC-B806-42ECB2B48606" |
Add event metadata
Event metadata is more detailed information associated with specific actions or events. Setting up metadata shares more performance insights, and using a consistent Conversion ID is crucial when using both the Pixel and CAPI for deduplication purposes.
To set up event metadata manually, you'll need to add the metadata parameters you want to a conversion event. We recommend keeping the base PageVisit
event and passing metadata values in a separate event on the same page.
We recommend adding these parameters to the init call. If this information isn't known at page load, you can add them to the track call.
rdt('track', 'AddToCart', {
itemCount: 2,
value: 19.99,
conversionId: 'UniqueConversionID',
currency: 'USD'
});
Reference
Parameter | Example |
---|---|
itemCount (integer) | itemCount: 2 |
value (float) | value: 19.99 |
currency (string) | currency: 'USD' |
conversionId (string) |
|
products (array) |
|