Skip to main content

Install the Reddit Pixel on Shopify

Looking for another way to track Reddit conversions? Install the Pixel using Google Tag Manager or one of our third-party integrations instead.

Adding a Reddit Pixel on your Shopify site is a great way to track visitor conversions from the Reddit Ads dashboard. There are two ways to set up the pixel on Shopify:

  • Shopify custom pixel: Pair Shopify standard events with Reddit conversion events. We recommend this method if you'd like to add dynamic metadata to your conversion events. This method requires more coding, so reach out to your developers for support if needed.
  • Edit your site template: Add your Pixel base code to your site's code. You'll be able to easily set up conversion events with the point-and-click event setup tool, making setting up conversion events easier. 

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.

Before you begin

  • Create a Reddit Ads account. Set up your business on Reddit Ads or join your team's account as an administrator. If you're using the v2 integration, your account team must allow the Pixel IDs you want to connect in Business > Accounts. Don't have an account? Here's a great place to start
  • Find your Reddit Pixel ID. Specify which business account should receive your conversions. You can find your Pixel ID in the Events Manager, and it should match the business account's Pixel ID found in Accounts.
  • Create a Shopify admin account. Set up your website on Shopify or join your business's team as an admin. 
  • (Site template only) Upgrade to Shopify Plus. Upgrade your Shopify plan to add conversion events to your checkout and order confirmation pages.

Create a custom pixel in Shopify

  1. In the Shopify admin panel, go to Settings > Customer events.
  2. Select Add custom pixel.
  3. Provide a name for your pixel. We suggest setting this to Reddit Pixel.
  4. Clear all the text in the code box.
  5. Paste your Reddit Pixel code. This will be used to initialize the Reddit Pixel. We recommend using this as a template:
    !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','a2_fvv2tn6ksw27', {
    "optOut": false,
    "useDecimalCurrencyValues":true
    });

    analytics.subscribe("page_viewed", (event) => {
    rdt('track', 'PageVisit', {
    conversionId: event.id
    });
    });

    analytics.subscribe("product_viewed", (event) => {
    rdt('track', 'ViewContent', {
    conversionId: event.id,
    products: {
    id: event.data.productVariant.sku,
    category: event.data.productVariant.product.type,
    name: event.data.productVariant.product.title
    }
    });
    });

    analytics.subscribe("product_added_to_cart", (event) => {
    const cartLine = event.data.cartLine;
    rdt('track', 'AddToCart', {
    conversionId: event.id,
    currency: cartLine.merchandise.price.currencyCode,
    value: cartLine.cost.totalAmount.amount,
    itemCount: cartLine.quantity,
    products: {
    id: cartLine.merchandise.sku,
    category: cartLine.merchandise.product.type,
    name: cartLine.merchandise.product.title
    }
    });
    });

    analytics.subscribe("checkout_completed", (event) => {
    const checkout = event.data.checkout;
    rdt('track', 'Purchase', {
    //customer match keys
    email: checkout.email,
    phoneNumber: checkout.phone,

    //event metadata
    currency: checkout.currencyCode,
    value: checkout.totalPrice.amount,
    itemCount: checkout.lineItems.reduce((total, item) => total + item.quantity, 0),
    conversionId: checkout.order.id,
    products: checkout.lineItems.map(item => ({
    id: item.variant.sku,
    category: item.variant.product.type,
    name: item.title
    }))
    });
    });

    Remember to replace {{Pixel ID}} with your Pixel ID, which you can find in the Events Manager.

    We've added the PageVisit, ViewContent, AddToCart, and Purchase events, and strongly recommend keeping them. However, feel free to remove any that you don't need to monitor them.

  6. (Optional) Link more customer events with Reddit's conversion events. You can do this using the analytics.subscribe() method. 

    We strongly recommend looking over your custom pixel before connecting it.

  7. When finished, select Save then Connect. When prompted, select Connect again. This will give the custom pixel access to your online store, checkout, and order confirmation page.

Edit your site template

Adding purchase events requires Shopify Plus. If you don't have access to Shopify Plus, we strongly suggest creating a custom pixel. In this case, you'll need to manually set up events instead of using the event setup tool.

  1. In the Events Manager, go to the Pixel Setup Guide and select Next.
  2. Select Copy to Clipboard to copy your Pixel code. Copy pixel code
  3. Update the init call to include match keys. This is highly recommended, especially when using the event setup tool to create conversion events. Learn more about setting up customer match keys.
    Example: Init call with match keys

    Remember to change the placeholder values.

    rdt('init', '<PIXEL-ID>', {
        email: '<EMAIL-HERE>',
    phoneNumber: '<PHONE-NUMBER-HERE>',
        externalId: '<EXTERNAL-ID-HERE>',
        idfa: '<IDFA-HERE>',
        aaid: '<AAID-HERE>',
    });
  4. In the Shopify admin panel, go to Online store > Themes.
  5. Select the ellipsis button then select edit code.
  6. Open the Layout > theme.liquid and  Layout > checkout.liquid files and paste the pixel code between the <head> tags.
  7. Save your changes.
  8. In the pixel setup guide, select Next to continue.
  9. Set up conversion events.

Learn more

Configure Signals

Validate Events

We're here to help

Our Reddit Ads team is ready to support you from setup to success.

Snoo Punch Up