### Singular Tracking Setup Source: https://business.reddithelp.com/s/article/Set-up-third-party-measurement This section outlines the parameters and provides examples for configuring Singular click and impression trackers for use with Reddit Ads. ```APIDOC ## Singular Tracking Setup ### Description Configure your Singular trackers with the correct parameters to ensure accurate event tracking and attribution for your Reddit Ads campaigns. ### Method N/A (Configuration via URL parameters) ### Endpoint N/A (Configuration via URL parameters) ### Parameters #### Path Parameters - **`[SINGULAR_ID]`** (string) - Required - Your Singular app ID or unique identifier. #### Query Parameters - **`aifa`** (string) - Required - Singular's parameter for GAID (Android Advertising ID). - **`pscid`** (string) - Required - Singular's parameter for Ad Group ID. - **`redirect`** (string) - Optional - Set to `false` to disable redirects. - **`pcid`** (string) - Required - Singular's parameter for Campaign ID. - **`pcrid`** (string) - Required - Singular's parameter for Creative ID. - **`reddit_advertiser_id`** (string) - Required - Your Reddit advertiser ID. - **`cl`** (string) - Required - Singular's parameter for Click ID. - **`idfa`** (string) - Required - Singular's parameter for IDFA (iOS Advertising ID). - **`pcn`** (string) - Optional - Singular's parameter for Campaign Name (impression tracker only). - **`reddit_impression_id`** (string) - Optional - Singular's parameter for Impression ID (impression tracker only). ### Request Example #### Valid Click Tracker ``` https://[YOUR_ADVERTISER_APP_DOMAIN].sng.link/[SINGULAR_ID]?aifa={{ANDROID_ADVERTISING_ID}}&pscid={{ADGROUP_ID}}&redirect=false&pcid={{CAMPAIGN_ID}}&pcrid={{AD_ID}}&reddit_advertiser_id={{ADVERTISER_ID}}&cl={{CLICK_ID}} ``` #### Valid Impression Tracker ``` https://i.sng.link/[SINGULAR_ID]?aifa={{ANDROID_ADVERTISING_ID}}&redirect=false&cl={{CLICK_ID}}&pcid={{CAMPAIGN_ID}}&pcrid={{AD_ID}}&pscid={{ADGROUP_ID}}&reddit_advertiser_id={{ADVERTISER_ID}}&pcn={{CAMPAIGN_NAME}} ``` ### Response #### Success Response (200) N/A (Tracking URLs typically return a redirect or a success status code without a response body). #### Response Example N/A ``` -------------------------------- ### Kochava Tracking Setup Source: https://business.reddithelp.com/s/article/Set-up-third-party-measurement This section details the required parameters and provides examples for setting up Kochava click and impression trackers for Reddit Ads. ```APIDOC ## Kochava Tracking Setup ### Description Configure your Kochava trackers with the correct parameters to ensure accurate event tracking and attribution for your Reddit Ads campaigns. ### Method N/A (Configuration via URL parameters) ### Endpoint N/A (Configuration via URL parameters) ### Parameters #### Path Parameters None #### Query Parameters - **`adgroup_id`** (string) - Required - The ID of the ad group. - **`advertiser_id`** (string) - Required - Your Kochava advertiser ID. - **`network_id`** (string) - Required - The network ID for Reddit (iOS: `7176`, Android: `7177`). - **`ad_id`** (string) - Required - The ID of the ad. - **`ad_name`** (string) - Optional - The name of the ad (for click trackers). - **`campaignID`** (string) - Required - The ID of the campaign. - **`click_id`** (string) - Required - A unique identifier for the click (for click trackers). - **`creative_id`** (string) - Required - The ID of the creative. - **`device_id`** (string) - Required - The device identifier (IDFA for iOS, GAID for Android). - **`pbr`** (string) - Optional - Server to server flag (set to `1` for click trackers). - **`utm_source`** (string) - Optional - Used for Android referrer tracking (e.g., `reddit_{{CLICK_ID}}`). - **`skad_source_identifier`** (string) - Optional - SKAdNetwork source ID (iOS only). - **`ad_platform`** (string) - Optional - Kochava platform type. ### Request Example #### Valid Click Tracker ``` https://control.kochava.com/v1/cpi/click?adgroup_id={{ADGROUP_ID}}&advertiser_id={{ADVERTISER_ID}}&network_id=7177&ad_id={{AD_ID}}&ad_name={{AD_NAME}}&campaignID={{CAMPAIGN_ID}}&click_id={{CLICK_ID}}&creative_id={{AD_ID}}&device_id={{ANDROID_ADVERTISING_ID}}&pbr=1&utm_source=reddit_{{CLICK_ID}} ``` #### Valid Impression Tracker ``` https://imp.control.kochava.com/track/impression?&device_id={{ANDROID_ADVERTISING_ID}}&advertiser_id={{ADVERTISER_ID}}&&ad_id={{AD_ID}}&network_id=7177&adgroup_id={{ADGROUP_ID}}&campaignID={{CAMPAIGN_ID}}&creative_id={{AD_ID}} ``` ### Response #### Success Response (200) N/A (Tracking URLs typically return a redirect or a success status code without a response body). #### Response Example N/A ``` -------------------------------- ### Reddit Pixel Initialization with Match Keys (JavaScript) Source: https://business.reddithelp.com/s/article/Install-the-Reddit-Pixel-on-your-website This JavaScript snippet demonstrates how to initialize the Reddit Pixel with customer match keys. It requires replacing placeholder values with your actual Pixel ID and customer information. This is crucial for accurate conversion tracking, especially when using the event setup tool. ```javascript rdt('init', '', { email: '', phoneNumber: '', externalId: '', idfa: '', aaid: '' }); ``` -------------------------------- ### Example User-Agent String Format Source: https://business.reddithelp.com/s/article/using-the-API-for-conversions This example demonstrates the recommended format for a unique and descriptive User-Agent string for Reddit API clients. It includes platform, application ID, version, and contact information. ```text User-Agent: android:com.example.myredditapp:v1.2.3 (by /u/kemitche) ``` -------------------------------- ### Example FFmpeg Commands for Conversion and Cropping Source: https://business.reddithelp.com/s/article/convert-tiktok-ads-to-reddit-video-ads This section provides a consolidated example of using FFmpeg for both video conversion (with re-encoding) and subsequent cropping/resizing. It demonstrates a common workflow for preparing video ads. The first command converts an MPEG file to MP4, and the second crops and resizes the resulting MP4 file. ```bash # Convert video and encode ffmpeg -i input.mpeg -c:v libx264 -c:a aac input.mp4 # Crop and resize ffmpeg -i input.mp4 -vf "crop=1080:1080,scale=1920:1080" output.mp4 ``` -------------------------------- ### Reddit API User Agent Format Example Source: https://business.reddithelp.com/s/article/using-the-API-for-conversions This example demonstrates the recommended format for the User-Agent string when interacting with the Reddit API. It should include platform, app ID, version, and contact information. ```text User-Agent: android:com.example.myredditapp:v1.2.3 (by /u/anagtest) ``` -------------------------------- ### Adjust Impression Tracker Example Source: https://business.reddithelp.com/s/article/Set-up-third-party-measurement This is an example of a valid impression tracker URL for the Adjust measurement partner. It is used for tracking ad impressions and includes relevant parameters. ```url https://view.adjust.com/impression/[ADJUST_ID]?gps_adid={{ANDROID_ADVERTISING_ID}}&reddit_advertiser_id={{ADVERTISER_ID}}&reddit_campaign_id={{CAMPAIGN_ID}}&reddit_adgroup_id={{ADGROUP_ID}}&reddit_ad_id={{AD_ID}}&reddit_click_id={{CLICK_ID}}&redirect=none ``` -------------------------------- ### Install and Configure Reddit Conversions API Extension Source: https://business.reddithelp.com/s/article/adobe-event-forwarding-extension Steps to install and configure the Reddit Conversions API extension within Adobe Experience Platform's event forwarding. ```APIDOC ## Install and configure the extension > **Important:** Depending on your implementation needs, you may need to create a schema, data elements, and a dataset before configuring the extension. Review all configuration steps beforehand to determine which entities you need for your use case. 1. Create an event forwarding property or choose an existing property to install the extension. 2. Select _Extensions_ in the left navigation. Open the _Catalog_ tab and select the card for the Reddit extension. 3. Provide your Pixel ID and conversion access token. When done, select _Save_. ``` -------------------------------- ### Adjust Click Tracker Example Source: https://business.reddithelp.com/s/article/Set-up-third-party-measurement This is an example of a valid click tracker URL for the Adjust measurement partner. It includes various parameters for tracking ad performance across different dimensions. ```url https://app.adjust.com/[ADJUST_ID]?gps_adid={{ANDROID_ADVERTISING_ID}}&reddit_advertiser_id={{ADVERTISER_ID}}&reddit_click_id={{CLICK_ID}}&reddit_adgroup_id={{ADGROUP_ID}}&reddit_campaign_id={{CAMPAIGN_ID}}&reddit_ad_id={{AD_ID}}&redirect=none&external_click_id=reddit_{{CLICK_ID}} ``` -------------------------------- ### Deduplicated CAPI and Pixel Event Setup Source: https://business.reddithelp.com/s/article/Install-the-Reddit-Pixel-on-your-website This snippet demonstrates how to set up deduplication for events shared between Reddit CAPI and Pixel. It requires a matching 'conversion_id' in CAPI and 'conversionId' in Pixel, along with matching event names, to ensure events are not double-counted. The CAPI example uses a curl command to send events to the Reddit Ads API, while the Pixel example shows the JavaScript implementation. ```curl curl 'https://ads-api.reddit.com/api/v2.0/conversions/events/{{Account ID}}' \ --header 'Authorization: Bearer {{auth_token}}' \ --data-raw '{ "test_mode": true, "events": [ { "event_at": "2024-10-31T19:37:45.380828", "event_type": { "tracking_type": "Custom", "custom_event_name": "Promotion" }, "event_metadata": { "conversion_id": "MySharedConversionID1" } } ] }' ``` ```javascript rdt('track', 'Custom', { customEventName: 'Promotion', conversionId: 'MySharedConversionID1' }); ``` -------------------------------- ### Singular Click Tracker Example Source: https://business.reddithelp.com/s/article/Set-up-third-party-measurement An example of a valid Singular click tracker URL. This URL facilitates the tracking of clicks and subsequent user actions within the Singular attribution platform. ```url https://[YOUR_ADVERTISER_APP_DOMAIN].sng.link/[SINGULAR_ID]?aifa={{ANDROID_ADVERTISING_ID}}&pscid={{ADGROUP_ID}}&redirect=false&pcid={{CAMPAIGN_ID}}&pcrid={{AD_ID}}&reddit_advertiser_id={{ADVERTISER_ID}}&cl={{CLICK_ID}} ``` -------------------------------- ### Kochava Click Tracker Example Source: https://business.reddithelp.com/s/article/Set-up-third-party-measurement An example of a valid Kochava click tracker URL. This URL includes various parameters required for tracking user clicks and attributing them to specific campaigns, ad groups, and ads. ```url https://control.kochava.com/v1/cpi/click?adgroup_id={{ADGROUP_ID}}&advertiser_id={{ADVERTISER_ID}}&network_id=7177&ad_id={{AD_ID}}&ad_name={{AD_NAME}}&campaignID={{CAMPAIGN_ID}}&click_id={{CLICK_ID}}&creative_id={{AD_ID}}&device_id={{ANDROID_ADVERTISING_ID}}&pbr=1&utm_source=reddit_{{CLICK_ID}} ``` -------------------------------- ### Event Structure with Match Keys Source: https://business.reddithelp.com/s/article/using-the-API-for-conversions Example JSON structure for sending conversion events with various user identifiers (match keys) to improve attribution accuracy. ```JSON { "events": [ { "click_id": "12345", "user": { "ip_address": "192.168.0.1", "user_agent": "Chrome/98.0.4758.102", "screen_dimensions": { "width": 1920, "height": 1080 }, "uuid": "1677712978045.b8f7eb7d-b357-437b-8bd3-e1c8166c7132", "email": "example@email.com", "phone_number": "+15554441234", "external_id": "customer12345", "idfa": "8A2E4F6D-0852-4B2A-B9D5-79334DE14B16", "aaid": "38400000-8cf0-11bd-b23e-10b96e40000d" } } ] } ``` -------------------------------- ### Kochava Impression Tracker Example Source: https://business.reddithelp.com/s/article/Set-up-third-party-measurement An example of a valid Kochava impression tracker URL. This URL is used to track ad impressions and is essential for measuring ad visibility and engagement. ```url https://imp.control.kochava.com/track/impression?&device_id={{ANDROID_ADVERTISING_ID}}&advertiser_id={{ADVERTISER_ID}}&&ad_id={{AD_ID}}&network_id=7177&adgroup_id={{ADGROUP_ID}}&campaignID={{CAMPAIGN_ID}}&creative_id={{AD_ID}} ``` -------------------------------- ### Example Google Campaign Manager (CM360) Tracker URL Source: https://business.reddithelp.com/s/article/Set-up-third-party-measurement Provides an example of a CM360 tracker URL used for conversion tracking. This URL format is crucial for routing traffic through CM360 to ensure accurate attribution and metric reporting. The presence of '/trackclk' is vital for full tracking functionality. ```url https://ad.doubleclick.net/ddm/trackclk/N7480.131843REDDIT.COM/B9916847.380155424;dc_trk_aid=571094499;dc_trk_cid=204640122;dc_lat=;dc_rdid=;tag_for_child_directed_treatment=;tfua=;ltd=;dc_tdv=1 ``` -------------------------------- ### Singular Impression Tracker Example Source: https://business.reddithelp.com/s/article/Set-up-third-party-measurement An example of a valid Singular impression tracker URL. This URL is used to track ad impressions within the Singular platform, providing data on ad visibility. ```url https://i.sng.link/[SINGULAR_ID]?aifa={{ANDROID_ADVERTISING_ID}}&redirect=false&cl={{CLICK_ID}}&pcid={{CAMPAIGN_ID}}&pcrid={{AD_ID}}&pscid={{ADGROUP_ID}}&reddit_advertiser_id={{ADVERTISER_ID}}&pcn={{CAMPAIGN_NAME}} ``` -------------------------------- ### Example Reddit Ads API Authorization URL Generation Source: https://business.reddithelp.com/s/article/authenticate-your-developer-application An example demonstrating the construction of an authorization URL for the Reddit Ads API using specific credentials. This example includes a sample App ID, Redirect URL, and scope for posting conversion events. ```text https://www.reddit.com/api/v1/authorize?client_id=DnvSjQYG9t13lWWOndNqOg&response_type=code&state=sgtm-capi&redirect_uri=https://www.reddit.com/prefs/apps&duration=permanent&scope=adsconversions ``` -------------------------------- ### Add Purchase Metadata Manually with JavaScript Source: https://business.reddithelp.com/s/article/link-standard-events-to-conversion-events This example demonstrates manually adding metadata to a 'Purchase' event triggered by a 'Promotion Event'. It captures product details, conversion ID, currency, value, and item count. Note: This example contains potential inconsistencies in variable usage (e.g., cartLine vs. checkout) and may require adjustments. ```javascript analytics.subscribe("Promotion Event", (event) => { const { checkout } = event.data; rdt("track", "Purchase", { products: checkout.lineItems.map(item => ({ id: item.variant.sku, category: item.variant.product.type, name: item.title })), conversionId: event.data.checkout.event.id, currency: cartLine.merchandise.price.currencyCode, value: cartLine.cost.totalAmount.amount, itemCount: cartLine.quantity }); }); ``` -------------------------------- ### HTML Structure for Reddit Pixel Installation (HTML) Source: https://business.reddithelp.com/s/article/Install-the-Reddit-Pixel-on-your-website This HTML snippet shows the basic structure of a webpage where the Reddit Pixel code should be inserted. The pixel code needs to be placed within the `` tags of every page where you want to track conversion events. ```html ``` -------------------------------- ### Example Reddit Macro Usage in Tracker URL Source: https://business.reddithelp.com/s/article/Set-up-third-party-measurement Demonstrates how to integrate various Reddit macros into a tracker URL. Macros are used to dynamically insert data like campaign ID, advertising ID, and timestamps. Ensure correct parameter naming and ampersand separation for multiple parameters. ```url https://tag.demo.com/ads?campaign={{CAMPAIGN_ID}}&advID={{ADVERTISING_ID}}redditadgroup={{ADGROUP_ID}}&creative={{CREATIVE_ID}}×tamp={{CACHEBUSTER}} ``` -------------------------------- ### Supported Data Feed URLs for Reddit Ads Source: https://business.reddithelp.com/s/article/catalog-requirements Examples of valid URLs for product data feeds. URLs should be HTTPS, FTP, or SFTP and must not include credentials directly. UTM parameters or third-party tags should be added within the feed itself. ```text https://reddit.com/best_catalog.csv sftp://reddit.com/best_catalog.csv ftp://reddit.com/best_catalog.csv ``` -------------------------------- ### Example of a Test Mode Conversion Event Response Source: https://business.reddithelp.com/s/article/using-the-API-for-conversions A JSON response indicating that conversion events were validated but not processed, typically used in test mode. ```JSON { "message": "In test mode. 1 conversion events were validated but not processed." } ``` -------------------------------- ### Post Conversion Events Request Payload Example (JSON) Source: https://business.reddithelp.com/s/article/using-the-API-for-conversions This JSON payload demonstrates how to structure conversion events for posting to the Reddit Ads API. It includes options for test mode, test IDs, and detailed event information, including user data and metadata. ```json { "test_mode": true, "test_id": "string", "events": [ { "click_id": "3184742045291813272", "event_at": "2018-01-01T00:00:00Z", "event_at_ms": 1514764800000, "event_type": { "tracking_type": "Purchase", "custom_event_name": "string" }, "event_metadata": { "item_count": 5, "currency": "USD", "value": 1099, "value_decimal": 10.99, "conversion_id": "H72B9A4YXQ", "products": [ { "id": "item-213", "name": "Carne Asada Burrito", "category": "Food Items" } ] }, "user": { "email": "snoo@example.com", "phone_number": "+15554441234", "external_id": "7c73f2ae-a433-4d7b-9838-f467da98f48e", "uuid": "1684189007728.7c73f2ae-a433-4d7b-9838-f467da98f48e", "ip_address": "192.0.2.1", "user_agent": "Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:47.0) Gecko/20100101 Firefox/47.0", "idfa": "EA7583CD-A667-48BC-B806-42ECB2B48606", "aaid": "cdda802e-fb9c-47ad-9866-0794d394c912", "opt_out": true, "screen_dimensions": { "width": 3440, "height": 1440 }, "data_processing_options": { "modes": [ "LDU" ], "country": "US", "region": "US-CA" } } } ] } ``` -------------------------------- ### Example of a Successful Conversion Event Response Source: https://business.reddithelp.com/s/article/using-the-API-for-conversions A JSON response indicating that one conversion event was successfully processed by the Reddit Ads API. ```JSON { "message": "Successfully processed 1 conversion events." } ``` -------------------------------- ### Get Custom Event Report Fields Source: https://business.reddithelp.com/s/article/using-the-API-for-conversions To retrieve a report for a custom conversion event, you need to request specific fields using the `conversion_custom_event_{{index}}_{{field}}` format in your 'POST Get a report' request. The index corresponds to the order of custom events returned by the 'GET Last Fired At' endpoint. This method allows you to fetch conversion data based on your selected attribution window. ```json { "data": { // Additional fields here "custom_events": [ { "last_fired_at": "2024-03-12T00:58:29.862000+00:00", "name": "my_custom_conversion_event" }, { "last_fired_at": "2024-03-11T19:03:32+00:00", "name": "begin_checkout" }, { "last_fired_at": "2024-03-12T00:59:05.981000+00:00", "name": "login" }, { "last_fired_at": "2024-03-11T08:03:41.323000+00:00", "name": "select_item" }, { "last_fired_at": "2024-03-10T23:36:53.844000+00:00", "name": "share" } ] } } ``` -------------------------------- ### JSON Response Structure Example Source: https://business.reddithelp.com/s/article/using-the-API-for-conversions This is a sample JSON structure representing a typical response from the Reddit Help Business API. It includes a 'message' field of type string, which is commonly used to convey information about the request's outcome. This structure is often returned for successful operations or to provide details on errors. ```json { "message": "string" } ``` -------------------------------- ### CAPI and Pixel Event Deduplication Source: https://business.reddithelp.com/s/article/Install-the-Reddit-Pixel-on-your-website This section details how to set up deduplication for events shared between the Reddit Pixel and CAPI. It requires a matching Conversion ID and event name for each shared event. ```APIDOC ## CAPI and Pixel Event Deduplication ### Description To prevent double-counting events shared between the Reddit Pixel and CAPI, deduplication must be set up. Each event shared with both platforms requires a matching Conversion ID and event name. ### Method This involves configuring both CAPI and Pixel events to include a unique `conversionId` (for Pixel) or `conversion_id` (within `event_metadata` for CAPI) that is identical for the same event. ### Parameters #### CAPI Event Parameters - **`conversion_id`** (string) - Required - A unique identifier for the event, manually set for pixel events. #### Pixel Event Parameters - **`conversionId`** (string) - Required - A unique identifier for the event, manually set for pixel events. ### Request Example #### CAPI ```curl https://ads-api.reddit.com/api/v2.0/conversions/events/{{Account ID}}' \ --header 'Authorization: Bearer {{auth_token}}' \ --data-raw '{ "test_mode": true, "events": [ { "event_at": "2024-10-31T19:37:45.380828", "event_type": { "tracking_type": "Custom", "custom_event_name": "Promotion" }, "event_metadata": { "conversion_id": "MySharedConversionID1" } } ] }' ``` #### Pixel ```javascript rdt('track', 'Custom', { customEventName: 'Promotion', conversionId: 'MySharedConversionID1' }); ``` ### Response #### Success Response (200) Responses will vary based on the API endpoint called (CAPI or Pixel tracking function). #### Response Example (No specific response examples provided for deduplication setup itself, success is indicated by events being tracked without duplication.) ``` -------------------------------- ### Fetch Custom Event Report Data (JSON) Source: https://business.reddithelp.com/s/article/using-the-API-for-conversions This snippet demonstrates how to construct a JSON payload to request data for custom conversion events. It specifies the desired fields, start time, and end time for the report. Ensure that `{{index}}` and `{{field}}` are correctly formatted according to the API documentation. ```json { "data": { "fields": [ "conversion_custom_event_1_clicks", "conversion_custom_event_1_views" ], "starts_at": "2024-03-10T00:00:00Z", "ends_at": "2024-03-12T00:00:00Z" } } ``` -------------------------------- ### POST Get a report Source: https://business.reddithelp.com/s/article/using-the-API-for-conversions Retrieve reports for custom conversion events by specifying the event index and field in the request. This endpoint allows you to fetch detailed conversion data based on your selected attribution window. ```APIDOC ## POST /reports/custom_conversion_events ### Description Get a report for a custom conversion event by requesting `conversion_custom_event_{{index}}_{{field}}` in fields for `POST Get a report`. Reporting returns conversion data based on the attribution window selected in the Ads Manager. ### Method POST ### Endpoint /reports/custom_conversion_events ### Parameters #### Query Parameters - **fields** (string) - Required - A comma-separated list of fields to include in the report. For custom conversion events, use the format `conversion_custom_event_{{index}}_{{field}}`. - **start_date** (string) - Required - The start date for the report (YYYY-MM-DD). - **end_date** (string) - Required - The end date for the report (YYYY-MM-DD). - **attribution_window** (string) - Optional - The attribution window to use for the report (e.g., '7d', '14d', '28d'). Defaults to '7d'. ### Request Example ```json { "fields": [ "conversion_custom_event_1_conversions", "conversion_custom_event_2_value" ], "start_date": "2024-03-01", "end_date": "2024-03-12", "attribution_window": "14d" } ``` ### Response #### Success Response (200) - **data** (object) - Contains the report data. - **custom_events** (array) - An array of custom event objects, each containing `last_fired_at` and `name`. #### Response Example ```json { "data": { "custom_events": [ { "last_fired_at": "2024-03-12T00:58:29.862000+00:00", "name": "my_custom_conversion_event" }, { "last_fired_at": "2024-03-11T19:03:32+00:00", "name": "begin_checkout" } ], "conversion_custom_event_1_conversions": 15, "conversion_custom_event_2_value": 150.75 } } ``` ### Notes To map custom event labels to their indices, call `GET Last Fired At` and use the `custom_events` field in the response. The custom conversion events are listed by their index in ascending order, starting with 1. ``` -------------------------------- ### Track Standard Conversion Events with Reddit Pixel Source: https://business.reddithelp.com/s/article/manual-conversion-events-with-the-reddit-pixel This snippet demonstrates how to track standard conversion events using the rdt('track', 'EventName') function. It includes examples for 'AddToCart' and a table listing other supported standard events like 'PageVisit', 'ViewContent', 'Search', 'AddToWishlist', 'Purchase', 'Lead', and 'SignUp'. ```javascript // Example: Share a conversion event after the init call rdt('init','{{Your pixel ID}}'); const addToCartButton = document.getElementById('addToCart'); addToCartButton.addEventListener('click', () => rdt('track', 'AddToCart')); ``` ```html ``` ```javascript rdt('track', 'PageVisit'); ``` ```javascript rdt('track', 'ViewContent'); ``` ```javascript rdt('track', 'Search'); ``` ```javascript rdt('track', 'AddToCart'); ``` ```javascript rdt('track', 'AddToWishlist'); ``` ```javascript rdt('track', 'Purchase'); ``` ```javascript rdt('track', 'Lead'); ``` ```javascript rdt('track', 'SignUp'); ``` -------------------------------- ### Set Up Customer Match Keys with Reddit Pixel Source: https://business.reddithelp.com/s/article/manual-conversion-events-with-the-reddit-pixel This snippet demonstrates how to include customer match keys in your Reddit Pixel tracking calls. It shows examples of passing hashed or unhashed data for 'aaid', 'email', 'phoneNumber', 'externalId', and 'idfa' within a 'PageVisit' event. ```javascript rdt('track', 'PageVisit', { "aaid": "cdda802e-fb9c-47ad-9866-0794d394c912", "email": "alice@example.com", "phoneNumber": "+15554441234", "externalId": "customer12345", "idfa": "EA7583CD-A667-48BC-B806-42ECB2B48606" }); ``` -------------------------------- ### Website Retargeting Audience Creation (API) Source: https://business.reddithelp.com/s/article/custom-audiences This example outlines the process of creating a website retargeting audience using an API endpoint. It specifies the necessary parameters such as audience name, conversion events, and lookback window. This method is recommended for audiences exceeding one million users. ```json { "name": "My Website Visitors", "type": "WEBSITE", "config": { "pixel_id": "YOUR_PIXEL_ID", "conversion_events": ["Page Visit"], "lookback_window_days": 90 } } ``` -------------------------------- ### 2. Get your access token from the Reddit API Source: https://business.reddithelp.com/s/article/using-the-API-for-conversions Exchange the authorization code obtained in the previous step for an access token and a refresh token using a POST request to the `/api/v1/access_token` endpoint. ```APIDOC ## POST /api/v1/access_token ### Description Exchanges an authorization code for an access token and a refresh token. This token is used to make authenticated requests to the Reddit Ads API. ### Method POST ### Endpoint `https://www.reddit.com/api/v1/access_token` ### Parameters #### Request Body - **grant_type** (string) - Required - Must be set to `authorization_code`. - **code** (string) - Required - The authorization code received from the `/api/v1/authorize` endpoint. - **redirect_uri** (string) - Required - The same redirect URI used during the authorization step. ### Headers - **Content-Type**: `application/x-www-form-urlencoded` - **Authorization**: Basic authentication using your `client_id` and `secret` (Base64 encoded). - **User-Agent**: A custom string identifying your application (e.g., `{{Name}}`). ### Request Example ```bash curl -X POST https://www.reddit.com/api/v1/access_token \ -H 'content-type: application/x-www-form-urlencoded' \ -A '{{Name}}' \ -u '{{App ID}}:{{Secret}}' \ -d 'grant_type=authorization_code&code={{Redirect Code}}&redirect_uri={{Redirect URL}}' ``` ### Response #### Success Response (200) - **access_token** (string) - The access token for making API requests. - **token_type** (string) - The type of token, usually `bearer`. - **expires_in** (integer) - The time in seconds until the access token expires. - **refresh_token** (string) - A token used to obtain a new access token when the current one expires. - **scope** (string) - The scopes granted to this token. #### Response Example ```json { "access_token": "{{Access token}}", "token_type": "bearer", "expires_in": 3600, "refresh_token": "{{Refresh token}}", "scope": "adsread,adsconversions" } ``` ``` -------------------------------- ### Example API Response for Custom Event Report (JSON) Source: https://business.reddithelp.com/s/article/using-the-API-for-conversions This JSON structure represents a successful response from the Reddit Ads API when requesting custom conversion event data. It includes metrics for various conversion types, including custom events, and pagination details. The `metrics` array contains objects with key-value pairs for each reported metric. ```json { "data": { "metrics": [ { "conversion_purchase_clicks": 7, "conversion_purchase_views": 0, "conversion_custom_event_1_clicks": 56, "conversion_custom_event_1_views": 0, "conversion_custom_event_3_clicks": 36, "conversion_custom_event_3_views": 0 } ] }, "pagination": { // Additional fields here } } ``` -------------------------------- ### Hashing Phone Numbers with SHA-256 Source: https://business.reddithelp.com/s/article/using-the-API-for-conversions Canonicalizes and hashes phone numbers using SHA-256. Removes extensions and all non-numeric characters, ensures the number starts with '+', and then applies SHA-256 hashing to produce a 64-character lowercase hex string. Invalid formats will still be accepted but generate a warning. ```javascript function hashPhoneNumber(phoneNumber) { // Remove extension (assuming 'ext.' or 'extension' followed by numbers) let canonicalPhone = phoneNumber.replace(/\s*(ext|extension)\.?\s*\d+$/i, ''); // Remove all non-numeric characters except the leading '+' if present canonicalPhone = canonicalPhone.replace(/[\s\-\(\)]/g, ''); // Ensure the number starts with '+' if it's a valid phone number format // This logic might need refinement based on expected input variations if (!canonicalPhone.startsWith('+') && canonicalPhone.length > 0) { // Assuming a default country code if not present, or handle as error // For simplicity, let's assume it should start with a digit that implies country code // A more robust solution would involve a phone number parsing library canonicalPhone = '+' + canonicalPhone; // Basic assumption } // SHA-256 hash (implementation depends on crypto library) // Example using Node.js crypto module: // const crypto = require('crypto'); // const hash = crypto.createHash('sha256').update(canonicalPhone).digest('hex'); // return hash; // Placeholder for actual hashing logic console.log('Canonicalized Phone:', canonicalPhone); return 'hashed_phone_placeholder'; } ``` ```python import hashlib import re def hash_phone_number(phone_number): # Remove extension canonical_phone = re.sub(r'\s*(ext|extension)\.?\s*\d+$', '', phone_number, flags=re.IGNORECASE) # Remove all non-numeric characters except the leading '+' if present canonical_phone = re.sub(r'[^+\d]', '', canonical_phone) # Ensure the number starts with '+' if it's a valid phone number format # Basic check: if it doesn't start with '+' and has digits, prepend '+' if not canonical_phone.startswith('+') and re.match(r'^\d+$', canonical_phone): canonical_phone = '+' + canonical_phone # SHA-256 hash hash_object = hashlib.sha256(canonical_phone.encode()) return hash_object.hexdigest() # Example usage: # print(hash_phone_number('+1 (555) 444-1234 ext. 789')) ``` -------------------------------- ### Get Access Token Source: https://business.reddithelp.com/s/article/authenticate-your-developer-application This endpoint allows you to obtain an access token by providing your application credentials and an authorization code. The access token is required to make authenticated requests to the Reddit Ads API. ```APIDOC ## POST /api/v1/access_token ### Description Obtain an access token for the Reddit Ads API using authorization code grant. ### Method POST ### Endpoint https://www.reddit.com/api/v1/access_token ### Parameters #### Query Parameters None #### Request Body - **grant_type** (string) - Required - Must be 'authorization_code'. - **code** (string) - Required - The authorization code obtained from the user. - **redirect_uri** (string) - Required - The redirect URI used during the authorization request. ### Request Example ```curl curl -X POST https://www.reddit.com/api/v1/access_token \ -H 'content-type: application/x-www-form-urlencoded' \ -A 'SGTM-CAPI' \ -u 'DnvSjQYG9t13lWWOndNqOg:Ucr7PXIWe_OK_vAsrE0J3kvDJ0faww' \ -d 'grant_type=authorization_code&code=QGRMgx3l54x0s8NT_WdcuSt_Adi9nA&redirect_uri=https://www.reddit.com/prefs/apps' ``` ### Response #### Success Response (200) - **access_token** (string) - The obtained access token. - **token_type** (string) - The type of token, usually 'bearer'. - **expires_in** (integer) - The time in seconds until the access token expires. - **refresh_token** (string) - A token to refresh the access token when it expires. - **scope** (string) - The scopes granted to this access token. #### Response Example ```json { "access_token": "{{Access token}}", "token_type": "bearer", "expires_in": {{Expiration time in Unix epoch}}, "refresh_token": "{{Refresh token}}", "scope": "{{Scope string}}" } ``` ``` -------------------------------- ### Website Retargeting Audience Creation (JavaScript) Source: https://business.reddithelp.com/s/article/custom-audiences This snippet demonstrates how to configure the Reddit Pixel for website retargeting. It includes enabling first-party cookies and setting up event tracking. Ensure the Reddit Pixel is correctly installed on your website before implementing this. ```javascript rdt('track', 'Page Visit'); // or other conversion events like 'Purchase', 'AddToCart', etc. // To disable first-party cookies (if necessary, though not recommended for retargeting): // rdt('disableFirstPartyCookies'); ``` -------------------------------- ### Extract Code Value from Redirect URL Source: https://business.reddithelp.com/s/article/authenticate-your-developer-application This example illustrates how to extract the authorization 'code' value from a redirect URL after a user has authorized your application. The code is typically found in the URL's query parameters and may have trailing characters like '#_' that need to be removed. ```text https://notarealbrand.myshopify.com/oauth/callback?state=my-state&code=Ve49meZ9oh3lZFY35CEizm3jTsfJeA#_ -> Ve49meZ9oh3lZFY35CEizm3jTsfJeA ``` -------------------------------- ### Get Reddit API Access Token using cURL Source: https://business.reddithelp.com/s/article/authenticate-your-developer-application This snippet demonstrates how to obtain an access token from the Reddit API using a cURL command. It requires your application's client ID, secret, and a redirect code. The output includes the access token, token type, expiration time, refresh token, and scope. ```bash curl -X POST https://www.reddit.com/api/v1/access_token \ -H 'content-type: application/x-www-form-urlencoded' \ -A 'SGTM-CAPI' \ -u 'DnvSjQYG9t13lWWOndNqOg:Ucr7PXIWe_OK_vAsrE0J3kvDJ0faww' \ -d 'grant_type=authorization_code&code=QGRMgx3l54x0s8NT_WdcuSt_Adi9nA&redirect_uri=https://www.reddit.com/prefs/apps' ``` -------------------------------- ### Set up Campaign Manager Tracker in Destination URL Source: https://business.reddithelp.com/s/article/Set-up-third-party-measurement Instructions for setting up the Campaign Manager 360 (CM360) tracker in the destination URL to measure conversions and view metrics in the CM360 dashboard. ```APIDOC ## Set up the Campaign Manager tracker in the destination URL ### Description This section guides users on how to configure their destination URLs to include the CM360 tracker for conversion measurement and metric reporting within the CM360 dashboard. ### Step 1: Check your destination URL Ensure your destination URL is set to the CM360 domain before redirecting to the final landing page. This is crucial for accurate tracking and attribution. ### URL Format Example ``` https://ad.doubleclick.net/ddm/trackclk/N7480.131843REDDIT.COM/B9916847.380155424;dc_trk_aid=571094499;dc_trk_cid=204640122;dc_lat=;dc_rdid=;tag_for_child_directed_treatment=;tfua=;ltd=;dc_tdv=1 ``` ### Important Note Verify that your URL contains `/trackclk`. If this path is missing, tracking capabilities may be limited, potentially impacting campaign performance, retargeting, audiences, and conversion metrics. ``` -------------------------------- ### Google Tag API: Sign Up Event Source: https://business.reddithelp.com/s/article/set-up-the-pixel-with-gtm This JavaScript snippet demonstrates how to send a 'sign_up' event using the Google Tag API. It records the sign-up method, currency, value, and user data, helping to track user registrations and their value. ```javascript ``` -------------------------------- ### Set up Customer Match Keys Source: https://business.reddithelp.com/s/article/manual-conversion-events-with-the-reddit-pixel This section explains how to include customer match keys (email, phone number, external ID, IDFA, AAID) with your conversion events to improve match rates. ```APIDOC ## POST /track (with Customer Match Keys) ### Description This endpoint allows you to track conversion events and include customer match keys to enhance conversion tracking across devices and browsers. ### Method POST ### Endpoint / ### Parameters #### Query Parameters - **event** (string) - Required - The name of the event to track (e.g., 'PageVisit'). - **properties** (object) - Required - An object containing customer match keys and other event metadata. - **email** (string) - Optional - Customer's email address (unhashed or SHA-256 hashed). - **phoneNumber** (string) - Optional - Customer's phone number (unhashed or SHA-256 hashed). - **externalId** (string) - Optional - A unique identifier for the customer (unhashed or SHA-256 hashed). - **idfa** (string) - Optional - Identifier for Advertisers (IDFA) (unhashed or SHA-256 hashed). - **aaid** (string) - Optional - Android Advertising ID (AAID) (unhashed or SHA-256 hashed). ### Request Example ```javascript // Track 'PageVisit' with customer match keys rdt('track', 'PageVisit', { "aaid": "cdda802e-fb9c-47ad-9866-0794d394c912", "email": "alice@example.com", "phoneNumber": "+15554441234", "externalId": "customer12345", "idfa": "EA7583CD-A667-48BC-B806-42ECB2B48606" }); ``` ### Response #### Success Response (200) No specific response body is detailed, but the event with customer match keys is registered. #### Response Example (No explicit response example provided in the documentation) ``` -------------------------------- ### Conversions API (CAPI) - Direct Integration Source: https://business.reddithelp.com/s/article/using-the-API-for-conversions Information on setting up the Conversions API (CAPI) through direct server-to-server integration for sharing conversion event data with Reddit Ads. ```APIDOC ## Conversions API (CAPI) - Direct Integration ### Description The Conversions API (CAPI) allows for secure server-to-server data transfer of conversion events to Reddit Ads. Direct integration offers maximum flexibility and control over your data, but requires in-house developer resources. ### Setup Recommendation This method is recommended if you require granular control over your data and have development resources available. ### Integration Resources Contact your Reddit account manager for additional integration resources and support. ### Note on Versions Conversions API v3 is now available and recommended for migration to leverage new features and long-term support. ``` -------------------------------- ### 1. Authorize your application Source: https://business.reddithelp.com/s/article/using-the-API-for-conversions Navigate to the Reddit authorization URL with your application's details to initiate the authorization process. This step generates a temporary code required for obtaining an access token. ```APIDOC ## GET /api/v1/authorize ### Description Initiates the OAuth 2.0 authorization flow to grant your application access to user data or perform actions on behalf of the user. ### Method GET ### Endpoint `https://www.reddit.com/api/v1/authorize` ### Parameters #### Query Parameters - **client_id** (string) - Required - The ID of your Reddit application. - **response_type** (string) - Required - Must be set to `code`. - **state** (string) - Required - A random string to prevent CSRF attacks. Can be any string without spaces or special characters. - **redirect_uri** (string) - Required - The redirect URL configured for your Reddit application. - **duration** (string) - Optional - Specifies the expiration of the access token. Can be `permanent` or `temporary` (expires in 1 hour). - **scope** (string) - Optional - A comma-separated list of permissions your application requests. Accepted values: `adsread`, `adsconversions`, `history`, `adsedit`, `read`. ### Request Example ``` https://www.reddit.com/api/v1/authorize?client_id={{App ID}}&response_type=code&state={{Random String}}&redirect_uri={{Redirect URL}}&duration={{Duration}}&scope={{Scope}} ``` ### Response Upon successful authorization, the user is redirected to the `redirect_uri` with `code` and `state` as query parameters. The `code` is a temporary credential. #### Success Response (Redirect) - **code** (string) - The authorization code. - **state** (string) - The state parameter sent in the request. #### Response Example (URL Parameters) `https://your-redirect-url.com/?state=your-state-string&code=authorization_code_value#_` ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.