Last updated 4 minutes ago

Cosmetic and Fixed Market Localization

The simplest form of price localization is to just convert and display prices in a user's local currency. This by itself can sometimes lead to suprisingly good results and achieve boosts in growth rates of 30-45%.

Only cosmetically localizing prices ignores differences in willingness to pay in different countries. For example, users in Nordic countries are often fine with paying a premium on base US prices. To adjust for these kinds of mispricings, prices can be adjusted by multiplying them with fixed adjustments, such as a countries PPP relative to the US. We call this Fixed Market Localization.

Localizing with Corrily

You can localize prices using the /prices/get endpoint.

To localize a price, simply send over a user_id and country, as well as a list of product ids. If you do not have access to a user's country, you can instead send us their IP. Depending on whether adjustments are applied at country level, the price returned will either be cosmetically localizer or localized with fixed market adjustments.

Call structure

user_id
string

Unique user identifier (required if ip is not specified)

ip
string

User IP address (required if country, user_id, or get_ip_from_request is not specified)

country
string

User two-letter country code (ISO 3166 alpha-2; required if ip is not specified)

ab
boolean

If set to true will enfore the ab flag. (If the ab flag is on the base price in the base currency, usually USD, will be returned.)

dev
boolean

Turn developement mode on/off. When set to false nothing will be stored by Corrily.

get_ip_from_request
boolean

For front-end calls, allows you to get the IP of the user from their request.

required
Array of objects (Product)

A list of product objects

Response structure

flag
string

An "AB" flag is returned if Corrily just returns the base price, if empty "", Corrily returns the locally-adjusted amount denominated in the local currency.

price
required
number

Price

price_monthly
number

Monthly price

local_price
required
number

Local price (in the user's local currency)

local_price_monthly
number

Local monthly price (in the user's local currency)

local_currency
required
string

Local currency code (ISO 4217)

local_currency_symbol
required
string

Local currency symbol (e.g. $, £, ...)

local_price_formatted
required
string

The local price, numerically formatted and with the symbol added (e.g. £500.00)

local_price_formatted_monthly
string

The local monthly price, numerically formatted and with the symbol added (e.g. £500.00)

stripe_amount
boolean

Amount in Stripe's format.

stripe_amount_monthly
boolean

Amount monthly in Stripe's format.

succeeded
required
boolean

Whether price prediction succeeded

Displaying prices

Below is React example of how prices can be displayed. Notice the failSafeValues which should always be available, just in case.

Example, unidentified user:

import React from "react";
import { useEffect, useState } from "react";

function Home() {
  const [corrilyResponse, setCorrilyResponse] = useState();

  useEffect(() => {
    const fetchData = async () => {
      // Adds a failsafe with timeout
      const controller = new AbortController();
      setTimeout(() => controller.abort(), 3000);

      // Default values to use in case of error
      // or timeout
      const failSafeValues = {
        products: {
          monthly_plan: {
            local_price_formatted: "$15"
          }
        }
      };
      try {
        const resp = await fetch("https://api.corrily.com/v1/prices/get", {
          method: "POST",
          signal: controller.signal,
          headers: {
            "Content-Type": "application/json",
            "X-API-KEY": "<API_KEY>"
          },
          body: JSON.stringify({
            // Do notice the dev flag, meaning no data will
            // be written to our db
            dev: true, // leave this on for now
            // ab: true,
            // get_ip_from_request: true,
            country: "GB", // two-letter country code
            user_id: "test-user-81234567",
            products: [{ product_id: "monthly_plan" }]
          })
        });

        if (resp.ok) {
          setCorrilyResponse(await resp.json());
        } else {
          setCorrilyResponse(failSafeValues);
        }
      } catch (e) {
        setCorrilyResponse(failSafeValues);
      }
    };
    fetchData();
  }, []);
  console.log(corrilyResponse);

  return (
    <div>
      <h1>Plans</h1>Monthly plan:{" "}
      {corrilyResponse
        ? corrilyResponse.products.monthly_plan.local_price_formatted
        : ""}
      {"/mo "}
      <br />
    </div>
  );
  
}
Copyright © Corrily 2020. All right reserved.