Different GEOs = Different $$ = JS for a fix

Erika in Glasses
2 min readApr 16, 2018

We build marketing landing pages for hot topic books and these landing pages can appear in different countries; sometimes it’s just CA and US, other times AU, NZ, and UK as well, and the fun fact about that is the book price is never the same. Sometimes the book cover is different as well. This used to mean creating a landing page code snippet for each country with the different information, it was time consuming and had a small chance for errors.

Then I got bored of having to do that and figured there had to be a better way to insert the information based on where the user is browsing from.

Thankfully our urls contain the geo and the lang the person is viewing the page in and I was able to use javascript to pull that information and have the correct price (for example) put in the price div.

This is what it looks like:

It’s pretty simple.

Location.pathname pulls the url path that appears after the domain, for example:


I used .substr to strips the first character and only keep two characters after


Then using a quick if statement I am able to match the geo and the price and have the text inserted into the div ebook-price.

It’s such a simple piece of code that has saved us about 30 minutes of development and scheduling time and almost an hour in the qa process. QAs only need to read the copy on one geo based page and check prices on the other pages. When there is a copy change it only needs to be made once, limiting errors of one geo being missed.

We’ve used this for inserting book prices, book covers, urls to different geos. As well as altering the end of the link:

It is set up a bit differently, as we needed to pull the LANG in as well, and store this, then used the GEO and the LANG to make up the end of the URL, saving us over two hours of work exporting the code and making a different file for each of the geos that land on this page.

A simple but effective piece of code.



Erika in Glasses

Web developer. Twitch Affiliate (erikainglasses). Youtuber. Olympic lifter. I write about code and streamer.