Skip to content

Reddit Pixel

The Reddit Pixel is a JavaScript snippet that loads Reddit’s tracking library so you can measure visits, conversions, and campaign performance from Reddit Ads.

AppIntegrated
UK✅
DE❌

Reddit Pixel requires the pixel’s base code. An overview of the integration methods can be found via the links below:

An overview of the debugging tools can be found via the links below:

Before integrating Reddit Pixel, note the following:

  • The provider only loads the pixel script in the browser after the configured consent requirements are met.
  • Event names and parameters should match the conversions defined in Reddit Ads.
  • Validate conversion values and currency when sending revenue events.
  • If Conversions API is used with the pixel, follow Reddit’s deduplication guidance so the same action is not counted twice; see the Advertising API documentation for technical details.

The @releafuk/analytics package provides a custom Reddit Pixel plugin through the redditPixelProvider() factory function. Reddit Pixel is integrated directly through the rdt tracking snippet.

The redditPixelProvider() factory accepts the config parameter that should satisfy the RedditPixelConfig type:

type RedditPixelConfig = {
pixelId: string;
enabled?: boolean;
nonce?: string;
};
OptionRequiredDefaultDescription
pixelIdYes-Reddit Pixel ID. An empty value makes the provider a no-op.
enabledNotrueControls whether the provider loads and initializes Reddit Pixel. Use false to keep the provider registered but disabled for an environment — every method becomes a no-op, including after consent is granted.
nonceNo-CSP nonce added to the dynamically loaded pixel script.

The provider injects https://www.redditstatic.com/ads/pixel.js during init, but only when the page has no pixel script already loaded. init also calls rdt("init", pixelId) and rdt("track", "PageVisit"), mirroring Reddit’s own base pixel snippet.

The provider is gated by requiredConsent: ["advertising"], so init only runs — and the script only loads — once the advertising consent key is granted.

Define Reddit Pixel event parameters under the redditPixel provider key, then register redditPixelProvider() when creating the analytics service:

import {
createAnalyticsService,
createEvent,
createEventDefinition,
createEventRegistry,
redditPixelProvider,
} from "@releafuk/analytics";
const purchase = createEvent<
{
orderId: string;
total: number;
currency: string;
},
"purchase"
>({
name: "purchase",
});
const events = createEventRegistry().register(
createEventDefinition(purchase, {
providers: {
redditPixel: (data) => ({
event: "Purchase",
params: {
value: data.total,
currency: data.currency,
conversionId: data.orderId,
},
meta: {
eventType: "purchase",
},
}),
},
}),
);
export const analytics = createAnalyticsService({
app: "releaf",
events,
providers: [
redditPixelProvider({
pixelId: import.meta.env.PUBLIC_REDDIT_PIXEL_ID,
}),
],
consent: {
default: {
analytics: "denied",
advertising: "denied",
functionality: "denied",
adUserData: "denied",
adPersonalization: "denied",
},
},
});
await analytics.init();

Only events mapped under the redditPixel key in an event’s createEventDefinition() are ever sent to Reddit — an event with no redditPixel mapping is silently skipped for this provider, so the event registry itself acts as the allowlist of events forwarded to Reddit Ads.

Mapped events are sent as rdt("track", "Custom", { customEventName: event, ...params }). Passing meta: { eventType: "purchase" }, as in the example above, additionally fires Reddit’s standard rdt("track", "Purchase", params) conversion event, so a single mapping can report both a custom event and a standard Purchase conversion.

Identify visitors with any known match keys so Reddit can better attribute conversions:

await analytics.identify({
userId: user.id,
traits: {
email: user.email,
phoneNumber: user.phoneNumber,
},
});

identify maps userId to externalId, and forwards email/phoneNumber from traits as Reddit match keys via rdt("init", pixelId, matchKeys). It is a no-op when none of these are available.