---
updatedAt: 2025-10-09T16:51:36.000Z
---

# Manually set up a post purchase event

> ❗️ Important
>
> Only use this method if you are unable to use the [Taboola Pixel app](https://developers.taboola.com/pixel/docs/conversion-tracking-for-shopify).

This page describes how to manually set up a post purchase event for your **post-purchase upsell app**in **Shopify**.

# Create a conversion rule in Realize

1. Open <a href="https://ads.realizeperformance.com/tracking" target="_blank">Realize</a>, and select the account (*top, left*) that you will use to track conversions.
2. In the sidebar (*left*), select `Tracking`.
3. Click on **`+ New conversion`** (*far right*). Then select **`Install events using code`** and click **`Continue`**.
4. Type in a `Conversion Name` of your choice - e.g. `Upsell Purchase`.
   > This is a descriptive name for your convenience.
5. For `Conversion Type`, select `EVENT`:

   <Image border={false} src="https://files.readme.io/5f13e3507036a532e31d31a0edc75535996be4f8391738dbb59470b0549bbffd-image.png" />
6. Leave `Fixed Value` blank (since this value is dynamic).
   > For additional guidelines, see the <a href="https://help.taboola.com/hc/en-us/articles/360003484314-Defining-and-Creating-Conversions" target="_blank">Help Center</a>.
7. Under `Category`, select `Make Purchase`.
8. Edit the `Event Name` to read `upsell_purchase` (or similar).
9. Make sure that the `Include in total value` and  `Include in total conversions` checkboxes are checked.
10. (*Optional*) If desired, tweak the values of the remaining fields.
    > For additional guidelines, see the <a href="https://help.taboola.com/hc/en-us/articles/360003484314-Defining-and-Creating-Conversions" target="_blank">Help Center</a>.
11. Scroll down to  the **`Event Code`** section, and select the relevant `dynamic parameters`.
    > Note how the code snippet updates accordingly.
    > For detailed guidelines, see: [Track dynamic conversion values](https://developers.taboola.com/pixel/docs/track-dynamic-values)
12. Review your chosen settings, and click on **`Create`** (*bottom, right*):

<Image border={false} src="https://files.readme.io/fa269a77ee497993379a201ca8816e4adccba89378d05b21619087e2462ca812-image.png" />

# Add a code snippet to Shopify

1. In your **Shopify** <a href="https://admin.shopify.com/" target="_blank">dashboard</a>, select **`Settings`** > **`Checkout`**.
2. Scroll down to **`Post-purchase page`** section.
3. Copy the code snippet provided below and paste it under `Additional scripts`.
   > Mouse over the code snippet and click on `copy` <img src="https://files.readme.io/700980d1b99a129034ef90c931e4643a85de8fb6c0e861d8045ce127f7b3d519-image.png" /> (*top, right*).
4. Edit the script and replace `DYNAMIC_ACCOUNT_ID` with your *own* **Taboola Account ID** on the first line.
   > See: [Tips & techniques >  Obtain your Account ID](https://developers.taboola.com/pixel/docs/tips-techniques#obtain-your-account-id)
5. Once you are done with your editing, click on **`Save`**.

   <Callout icon="🚧" theme="warn">
     Make sure to fill in your _own_ **Taboola Account ID**.
   </Callout>

```html
<script>
// Replace with your Taboola account ID
var TABOOLA_ACCOUNT_ID = 'DYNAMIC_ACCOUNT_ID';
var INTEGRATION_TYPE = 'SHOPIFY_APP';
window._tfa = window._tfa || [];
window._tfa.push({notify: 'event', name: 'page_view', id: TABOOLA_ACCOUNT_ID, it: INTEGRATION_TYPE});
!function (t, f, a, x) {
  if (!document.getElementById(x)) {
    t.async = 1;t.src = a;t.id=x;f.parentNode.insertBefore(t, f);
  }
}(document.createElement('script'),
document.getElementsByTagName('script')[0],
'//cdn.taboola.com/libtrc/unip/' + TABOOLA_ACCOUNT_ID + '/tfa.js',
'tb_tfa_script');
window.Shopify = window.Shopify || {};
if (Shopify.on) {
  Shopify.on('CheckoutAmended', function (newOrder, previousOrder) {
    try {
      console.log('[TaboolaPixel] CheckoutAmended event fired', newOrder, previousOrder);
  
      var oldItems = (previousOrder && previousOrder.lineItems) || [];
      var oldItemsIds = oldItems.map(function (item) {
        return item && item.id;
      });
  
      var newItems = (newOrder && newOrder.lineItems) || [];
      var addedItems = newItems.filter(function (item) {
        var itemId = item && item.id; 
        return itemId && oldItemsIds.indexOf(itemId) < 0;
      });
  
      console.log('[TaboolaPixel] Previous item IDs:', oldItems);
      console.log('[TaboolaPixel] Newly added items:', addedItems);
  
      if (addedItems.length === 0) {
        console.log('[TaboolaPixel] No new items detected — event will not be fired');
        return;
      }
  
      var totalQuantity = 0;
      var totalRevenue = addedItems.reduce(function (sum, item) {
        var finalPrice = (item && item.finalPrice) || 0;
        var quantity = (item && item.quantity) || 0;
        totalQuantity = totalQuantity + quantity;
        return sum + (finalPrice * quantity);
      }, 0);
      
      var currency = (newOrder && newOrder.currency) || 'USD';
      var newOrderId = (newOrder && newOrder.id) || '';
        
      var taboolaEvent = {
        notify: 'event',
        name: 'upsell_purchase',
        id: TABOOLA_ACCOUNT_ID,
        it: INTEGRATION_TYPE,
        revenue: totalRevenue,
        currency: currency,
        orderid: newOrderId,
        quantity: totalQuantity
      };
    
      console.log('[TaboolaPixel] Final event object:', taboolaEvent);
    
      _tfa.push(taboolaEvent);
        
      console.log('[TaboolaPixel] Event pushed to _tfa');
    } catch (error) {
      console.error('[TaboolaPixel] Error in CheckoutAmended handler:', error);
    }
  });
}
</script>
```

<br />