NOTE: We've introduced a new feature called Computed Events in Wingify Data360, which allows you to effortlessly set up currency conversions within Events and track your website conversions in any currency.
Running your business globally involves transactions in multiple currencies. And, should your website be hosted on an e-commerce platform like Shopify, you would often run into a situation where your revenue conversions are not reflected in your preferred currency; instead, they remain in the currency native to the visitor who made the purchase. They are more likely to cause discrepancies in your conversion evaluation, skewing your analysis.
To mitigate this, you can append a small code (just above your revenue code) that automatically converts your revenue conversions to your default currency setting.
INFO: Refer to this article to learn how to implement the revenue tracking code for your campaigns.
If you’re using the US Dollar as your default currency, then the currency conversion code will look like this:
ATTENTION: The following code involves manually applying revenue conversion rates with respect to your default currency. Do update the rates appropriately to be current.
function convertToDefaultCurrency(amount, fromCurrency, precision = 2) {
// For reference. Change USD to your default store currency
var defaultCurrency = "USD";
/**
* Your array of currencies and their conversion rates relative to the default currency
* Example: If USD is your store currency or the one in which you want to track revenue and
* 1 USD = 0.8 GBP then the entry in the array will be "GBP": 0.8
**/
var currencyConversion = {
USD: 1, // Always keep the default store currency in the array and keep the value as 1
EUR: 1.1, // Euro
GBP: 0.8, // Great British Pound
AUD: 1.43, // Australian Dollar
};
if (!currencyConversion[fromCurrency.toUpperCase()]) {
console.error("Unsupported currency code: {{ currency }}");
// Handling can be added for additional currencies
return null;
}
return (amount / currencyConversion[fromCurrency.toUpperCase()]).toFixed(
precision
);
}For Shopify
If you’re using Shopify to host your website, refer to the following example to know how to implement the currency conversion code along with the revenue conversion code:
Note: If you are using Shopify's Wingify app for integration, you can refer to this article to set up code customization, which also includes configuring multi-currency conversion.
<script>
(function () {
function convertToDefaultCurrency(amount, fromCurrency, precision = 2) {
var defaultCurrency = "USD";
var currencyConversion = {
"USD": 1, // Always keep the default store currency in the array
"EUR": 1.1, // Euro
"GBP": 0.82, // Great British Pound
"AUD": 1.43, // Australian Dollar
"CAD": 1.4, // Canadian Dollar
"CZK": 26, // Czech Koruna
"DKK": 7.3, // Danish Kroner
"HKD": 7.76, // Hong Kong Dollar
"ISK": 170, // Icelandic Krona
"ILS": 3.8, // Israeli New Shekel
"NZD": 1.43, // New Zealand Dollar
"NOK": 14, // Norwegian Kroner
"PLN": 4.6, // Polish Zloty
"RON": 5, // Romanian Leu
"SGD": 1.34, // Singaporean Dollar
"KRW": 1200, // South Korean Won
"SEK": 10.55, // Swedish Krona
"JPY": 120, // Japanese Yen
};
if (!currencyConversion[fromCurrency.toUpperCase()]) {
console.error("Unsupported currency code: {{ currency }}");
return null;
}
return (amount / currencyConversion[fromCurrency.toUpperCase()]).toFixed(precision);
}
// Example usage:
{% assign _vis_opt_revenue = total_price | divided_by: 100.0 %}
var revenue = {{ _vis_opt_revenue }};
var currency = "{{ currency }}";
var convertedAmount = convertToDefaultCurrency(revenue, currency);
// Do not change anything in the following two lines
window.VWO = window.VWO || [];
VWO.event = VWO.event || function () {VWO.push(["event"].concat([].slice.call(arguments)))};
VWO.event("purchase", {
"revenue": convertedAmount || revenue,
"currency": currency
});
})();
</script>