Skip to main content
All CollectionsSales TrackingSales Tracking Links
Multiple Currency Support for Link Tracking Offers
Multiple Currency Support for Link Tracking Offers

How to convert non-USD sale amounts to USD using an exchange rate API and server postback tracking for Link Offers

Simma Baghbanbashi avatar
Written by Simma Baghbanbashi
Updated over a week ago


Currently, in Aspire, all dollar amounts are tracked as USD. This article serves as an example of how a brand could use a custom solution to convert their order amounts to USD before sending it to Aspire to record a conversion. This is recommended for all Link Tracking Offers where you'll be offering commission per sale and working with international influencers.


  1. Technical ability to write custom Javascript code before the conversion is recorded.

  2. A link tracking offer with either Server Postback w/ Transaction ID or Server Postback w/ Partner ID as the conversion tracking method. You can also use Javascript SDK to implement Server Postback w/ Transaction ID.

  3. An exchange rate API key (this example uses Exchange Rates API -

    1. Please note that you must upgrade to a paid plan to use Exchange Rates API for this purpose. Their Basic plan (currently $10/month) provides up to 10,000 API requests per month and supports all base currencies.


Before calling the postback or SDK to indicate a conversion, you should use the Exchange Rate API (or a similar service) to convert the order amount to USD. After converting, you will pass the new USD order amount to the Aspire postback or SDK.

The example below is for a Shopify brand using Server Postback w/ Transaction ID (implemented via Javascript SDK) using Exchange Rate API. This is a script that a Shopify brand would enter in their Order Status Page under Additional Scripts under Checkout in Shopify. More information on Javascript SDK can be found here.

⚠️ Important: the following code is not one-size-fits-all and is merely given as an example to help your technical team implement a solution that meets your needs. This script is specific to Shopify brands using Exchange Rates API.

Example Code for Shopify brands using Exchange Rates API

{% if first_time_accessed %}
// Adding the Aspire SDK
!function(){var o=window.tdl=window.tdl||[];if(o.invoked)window.console&&console.error&&console.error("Tune snippet has been included more than once.");else{o.invoked = !0, o.methods = ["init", "identify", "convert"], o.factory = function (n) { return function () { var e =; return e.unshift(n), o.push(e), o } };for(var e=0;e<o.methods.length;e++){var n=o.methods[e];o[n]=o.factory(n)}o.init=function(e){var n=document.createElement("script");n.type="text/javascript",n.async=!0,n.src="";var t=document.getElementsByTagName("script")[0];t.parentNode.insertBefore(n,t),o.domain=e}}}(); tdl.init("")


async function convertToUSD(currencyCodeFrom, amount) {
// Documentation for this API:
const response = await fetch(`${EXCHANGE_RATES_API_KEY}&from=${currencyCodeFrom}&to=USD&amount=${amount}`,{method: 'GET' });
const result = await response.json();
return result.result;

async function recordAspireConversion() {
const cartSubtotalWithCurrency = '{{ subtotal_price | money_with_currency}}'
const cartSubtotalCurrencyCode = cartSubtotalWithCurrency.split(' ')[1];

const cartSubtotal = `{{ subtotal_price | money_without_currency | remove: ',' }}`

let cartSubtotalUSD = null;

if (cartSubtotalCurrencyCode === 'USD')
{cartSubtotalUSD = cartSubtotal; }
else {
try {
cartSubtotalUSD = await convertToUSD(cartSubtotalCurrencyCode, cartSubtotal);
} catch (error) {console.error('Error when converting cart subtotal to USD', error);}

tdl.convert({'amount': cartSubtotalUSD });

{% endif %}

Implementation Notes:

  • Enter the API key you received from Exchange Rates API in the placeholder value YOUR API KEY HERE in the snippet below:


  • Enter your store's currency in the placeholder value {currencyCodeFrom} in the snippet below:

    For example, if your store's local currency is GBP, you would replace {currencyCodeFrom} with GBP so it looks like this:${EXCHANGE_RATES_API_KEY}&from=GBP&to=USD&amount=${amount}

  • If you have multiple Shopify stores with non-USD store currencies, you must add this script to each Shopify store (excluding your US store).

Did this answer your question?