Post purchase upsell page
If your Shopify store uses a post-purchase upsell page (for an upsell app) additional setup is required to track the upsell purchases.
Create a conversion rule in Realize
-
Open Realize, and select the account (top, left) that you will use to track conversions.
-
In the sidebar (left), select
Tracking
. -
Click on
+ New conversion
(far right). Then selectInstall events using code
and clickContinue
. -
Type in a
Conversion Name
of your choice - e.g.Upsell Purchase
.This is a descriptive name for your convenience.
-
For
Conversion Type
, selectEVENT
: -
Leave
Fixed Value
blank (since this value is dynamic).For additional guidelines, see the Help Center.
-
Under
Category
, selectMake Purchase
. -
Edit the
Event Name
to readupsell_purchase
(or similar). -
Make sure that the
Include in total value
andInclude in total conversions
checkboxes are checked. -
(Optional) If desired, tweak the values of the remaining fields.
For additional guidelines, see the Help Center.
-
Scroll down to the
Event Code
section, and select the relevantdynamic parameters
.Note how the code snippet updates accordingly.
For detailed guidelines, see: Track dynamic conversion values -
Review your chosen settings, and click on
Create
(bottom, right):
Add a code snippet to Shopify
-
In your Shopify dashboard, select
Settings
>Checkout
. -
Scroll down to
Post-purchase page
section. -
Copy the code snippet provided below and paste it under
Additional scripts
.Mouse over the code snippet and click on
copy
(top, right).
-
Edit the script and fill in your own Taboola Account ID on the first line.
-
Once you are done with your editing, click on
Save
.Make sure to fill in your own Taboola Account ID.
<script> const TABOOLA_ACCOUNT_ID = '123'; // Replace '123' with your own Taboola Account ID. window._tfa = window._tfa || []; !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'); Shopify.on('CheckoutAmended', function (newOrder, previousOrder) { try { console.log('[TaboolaPixel] CheckoutAmended event fired', newOrder, previousOrder); const oldItems = (previousOrder.lineItems || []).map(function (line) { return line.id; }); const addedItems = (newOrder.lineItems || []).filter(function (line) { return oldItems.indexOf(line.id) < 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; } const totalRevenue = addedItems.reduce(function (sum, item) { return sum + (item.finalPrice * item.quantity); }, 0); const totalQuantity = addedItems.reduce(function (sum, item) { return sum + item.quantity; }, 0); const taboolaEvent = { notify: 'event', name: 'upsell_purchase', id: TABOOLA_ACCOUNT_ID, revenue: totalRevenue, currency: newOrder.currency || 'USD', orderid: newOrder.id || '', 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>
Updated about 12 hours ago