On my morning walks, I have been enjoying listening to SaaS related podcasts, and yesterday morning, I was listening to Jane Portman’s “UI Breakfast” podcast in which she was talking to Rob Turlinckx about SaaS Pricing pages.
Now, we have just done a revamp of our own HR Partner pricing page, which actually meets most of the suggestions of what they talked about in the podcast, i.e. offering multiple currencies, showing the user’s local currency automatically upon loading, showing monthly vs annual pricing etc.
Our HR Partner pricing page
Our page is quite complex (but thankfully I have a great UX designer on my team who made it as easy to use as possible), but I thought I would expand upon a couple of things that we did on there in order to display pricing in various currencies, and most importantly, how we detected the user’s location and showed them the relevant pricing in their own local currency (or else defaulting back to USD if they were in a location outside of our usual pricing).
What I have done is to put together a simple pricing page on Github which you are welcome to explore and dissect. My aim was to be able to achieve localised pricing with (a) minimal javascript code, (b) doing it all on one page and (c ) for absolutely FREE — no calling upon expensive landing page or A/B testing services to generate different pricing pages at all!
This is what it looks like (yep, I’m a coder, not a designer!):
Our test pricing page
Take a look at it running live here: https://cyberferret.github.io/LocalCurrencyPricing/
Here is a Gist of the actual web page code:
If you want the full source code (with the Bootstrap and jQuery libraries etc. so you can test on your own server), then you can clone my code from my Github repository: https://github.com/CyberFerret/LocalCurrencyPricing
Let’s break down the code here.
Firstly, I am using a simple Bootstrap 4 page layout, which has a header block, then 4 columns for the pricing. If you look at each pricing column though, I have included the 4 currencies that I want to show:
<div class="col-lg-3 col-md-6 mb-4"><div class="card"><div class="card-header"><h2 class="text-primary">FREE</h2></div><div class="card-body"><h4 class="card-title pricing USD_pricing">USD $0</h4><h4 class="card-title pricing GBP_pricing collapse">GBP £0</h4><h4 class="card-title pricing EUR_pricing collapse">EUR €0</h4><h4 class="card-title pricing AUD_pricing collapse">AUD $0</h4><p class="card-text text-info">Our free plan will suit the Scrooge McDuck's among you.</p></div><div class="card-footer"><a href="#" class="btn btn-primary">Find Out More!</a></div></div></div>
But have a look at the `collapse` class used in all but the USD pricing in the source code. What this does is ‘collapses’ the other currencies so that they are not visible upon page load, instead showing you the USD pricing as a default.
I have also given all the pricing <h4> tags the class of `pricing` and `XXX_pricing` (where XXX is the 3 letter currency code for each locale). You will see how I use these later to both hide and show the relevant pricing via a simple javascript function.
Now lets look at the javascript code at the bottom of the page. There are two blocks we need to look at, namely:
$(document).ready(function () {$.get("https://api.ipdata.co?api-key=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", function (response) {var detectedCurrency = response.currency.code;displayPrice(detectedCurrency)}, "jsonp");});
This bit of code waits until the page is completely loaded, then goes off to the IPData.co free service to query the user’s locale information, including the currency code associated with their locale.
This information is contained within the JSON response from the IPData service, and you can get to it via the response.currency.code variable.
Be warned that this call, even though it is done as a background asynchronous AJAX call, can take a few seconds to return a result — which is why we show the default USD pricing initially, rather than no pricing at all. This can cause a disconcerting flicker upon page load, so you may want to show NO pricing on your own page as a default, which you can do by adding the `collapse` class to ALL pricing lines initially. It is entirely up to you.
TIP: Just remember to replace the ‘xxxxxxxxx’ dummy API key above with your free one that you get from IPData.co!
The next bit of javascript is the one that manipulates the page DOM to show or hide the relevant currencies:
displayPrice = function(currency) {// First, lets hide all the current pricing$(".pricing").hide();// Is the currency within the valid range of currencies that we wish to show?if (currency !== null || (["USD", "AUD", "GBP", "EUR"].indexOf(currency) > -1)) {// If yes, then show the currency$("." + currency + "_pricing").show();} else {// If no, then just show USD pricing$(".USD_pricing").show();}}
This function takes just one parameter, the 3 letter currency code, and then it:
One last thing — I realise that sometimes users may want to see the pricing in other currencies themselves, rather than in their local currency. Most often when they want to compare the USD values against other services they use etc., so we should allow them the ability to do so.
Which is why I placed the button group between the header and the pricing boxes which asks for the currency they want to see. Clicking on any of the buttons will call the `displayPrice()` function to show that locale’s currency.
<div class="row text-center"><div class="col-lg-12 m-2"><p>Show me pricing in: </p><div class="btn-group mb-3" role="group" aria-label="Select Currency"><button type="button" class="btn btn-secondary" onclick="displayPrice('USD');">USD</button><button type="button" class="btn btn-secondary" onclick="displayPrice('GBP');">GBP</button><button type="button" class="btn btn-secondary" onclick="displayPrice('EUR');">EUR</button><button type="button" class="btn btn-secondary" onclick="displayPrice('AUD');">AUD</button></div></div></div>
That’s it! Pretty easy (and cheap), isn’t it? No need for a complex content management system, or PHP/Ruby scripting etc. This can all be done on a free website hosting platform like Amazon S3 (which we use) or Github Pages etc.
Have fun with it. For my next post, I might showcase how to use a free foreign currency exchange API to dynamically calculate the other pricing based on that day’s exchange rates!