Geo personalised ads and content: show each visitor the facts that are true where they are
TL;DR
Difficulty: Intermediate
Location changes a few real facts: delivery speed and cost, whether the shop is close, what is in stock. Personalise those, keep the pitch the same.
- Trust the customer's own postcode first, the IP address only for the country or UK nation.
- In Google Ads choose presence or presence or interest on purpose. Meta now only offers people living in or recently in an area.
- Read the location from your host's header on each request and store nothing.
- Prove the lift with a holdout sized before you start.
Where a visitor is changes a handful of real facts, and a page that gets those facts right sells more than a page that guesses. In this article I show how I use location in ads, landing pages and email for an invented Leeds outdoor shop, from which location source to trust, through the ad platforms' targeting settings and UK law, to the test that proves it worked.
Location is a fact about the visitor, not a mood
Most talk about geo personalisation sounds like a magic trick: show the visitor their city, add a little urgency, watch the numbers climb. That framing is why so much of it goes wrong.
Where someone is changes a handful of real facts. How fast their order arrives. What delivery costs. Whether they can walk into your shop this afternoon. Whether the event you are advertising is a short bus ride away or a five hour drive. When a page tells each visitor the facts that are true for them, it helps. When it pretends to know more than it does, or invents urgency it cannot back up, it does the opposite.
So the test I use is simple. Would the page be wrong, or less useful, if it showed the same thing to everyone? If yes, personalise by place. If no, leave it alone, because every variant you add is one more thing to build, test and keep honest.
Everything in this article is my own way of working, stated as mine. Where I lean on an outside fact, mostly the ad platforms' own documentation and the Information Commission (the regulator was the ICO until September 2026, and its website still uses that name), it carries a footnote. The business in the examples is invented.
Worked example: meet the shop
Pennine Kit is an outdoor clothing shop in Leeds. It does not exist. Aisha, who runs it, sells waterproofs, walking boots and base layers online at penninekit.example, and runs a small shop near the station where she also does boot fitting. Her bestselling jacket costs £140.
Three people open that jacket's page on the same Tuesday morning. One is in Leeds. One is in Belfast. One is in Inverness. For the visitor in Leeds, the true facts are: next day delivery, or collect it from the shop today. For the visitor in Belfast, Aisha's courier takes three working days and charges £6.95. For the visitor in Inverness, it takes two working days.
A single page that says "Free next day delivery" is true for one of the three and quietly false for the other two. That is the problem geo personalisation exists to solve. Not cleverness. Accuracy.
Where location comes from, and how far to trust it
Before you personalise anything, be honest about where the location came from. There are four sources, and they are not equally good.
The best is what the customer told you: a postcode typed into a delivery checker, or the address saved on their account. It is exact and they chose to give it.
Second is the browser's own location, from the Geolocation API. It is precise, but the browser asks the visitor for permission first, and it only works on secure (HTTPS) pages.1 On a shop I almost never ask.
Third is the IP address. Your host or CDN looks up the visitor's network address in a database and returns a best guess. It costs the visitor nothing and needs no prompt, which is why everyone reaches for it. It is also the weakest of the three. MaxMind, one of the main providers of these databases, publishes its own accuracy figures: for the United Kingdom, 68% of IP addresses are placed within 50 km of the true location, 21% are placed in a city but further away than that, and 11% get no city at all.2 Mobile networks, office networks and VPNs all blur it further.
Fourth is nothing. Some requests arrive with no usable location, and Cloudflare, for example, marks those with a special country code of XX, and visitors on the Tor network with T1.3 Your page needs a sensible default for them.
Read it from the top. The customer's own postcode wins whenever you have it. The IP lookup is a fallback, and it is only trusted for the coarse decision (which country, which nation of the UK). Anything finer than that, the page asks for.
Worked example: Aisha's month of visitors
Aisha looks at one month of traffic to her product pages: 10,000 visitors. Of those, 1,800 are signed in with a saved address. Another 600 type a postcode into the delivery checker on the page. That leaves 7,600 who gave her nothing, and for 300 of those the IP lookup returns no country either.
So for 7,300 visitors the only clue is the IP address. If she used it to promise something at city level, MaxMind's own UK figures say roughly a third would get it wrong or blank:
Here is the number of visitors located only by IP, is the share placed in the wrong city (more than 50 km away) and is the share with no city at all, so about visitors a month would see a city level promise that does not fit them. That is why Aisha uses IP only to tell England, Scotland, Wales and Northern Ireland apart, and puts a postcode checker beside the delivery line for everything finer.
Reading the location at the edge, without storing it
Most modern hosting already does the IP lookup for you and hands the answer to your code as a request header. You do not need your own database or a library that parses addresses.
On Vercel, the country arrives in x-vercel-ip-country as a two letter ISO code, and x-vercel-ip-country-region carries the first level region. Vercel's own documentation gives the British example: in the United Kingdom that region is a country like England, not a county like Devon.4 That is precisely the resolution Aisha needs. On Cloudflare, the country arrives in the CF-IPCountry header.3
Two corrections to code you will still find in older tutorials, including an older version of this article. First, Next.js removed the geo and ip properties from its request object in version 15, because those values come from the hosting provider, not the framework.5 Second, the file that runs before every request, long called middleware, is called proxy from Next.js 16 onwards.6 And do not read the visitor's address straight out of x-forwarded-for on your own: behind a proxy it can hold a list of addresses, and Cloudflare recommends its own CF-Connecting-IP header for exactly that reason.3
The third correction is mine, and it matters more than the other two. The old version set the visitor's country in a cookie. You do not need to. The header arrives on every request, so the page can decide afresh each time and store nothing in the visitor's browser. That keeps a whole category of consent questions off the table, which I come back to in the section on the law.
Worked example: Aisha's proxy file
Aisha's site runs on Next.js on Vercel. Her proxy reads the nation from the header and passes it to the page as a request header, so the page can render the right delivery line on the server. Nothing is written to the browser.
// proxy.js
import { NextResponse } from 'next/server'
const NATIONS = ['ENG', 'SCT', 'WLS', 'NIR']
export function proxy(request) {
const country = request.headers.get('x-vercel-ip-country') || ''
const region = request.headers.get('x-vercel-ip-country-region') || ''
// Trust the IP for one coarse decision only: which UK nation, or none.
const nation = country === 'GB' && NATIONS.includes(region) ? region : 'UNKNOWN'
const headers = new Headers(request.headers)
headers.set('x-penninekit-nation', nation)
return NextResponse.next({ request: { headers } })
}
export const config = { matcher: ['/products/:path*'] }
Step by step. A visitor on a Leeds mobile network arrives with country GB and region ENG, so the page receives ENG and shows "Next day to most of Great Britain, or collect in Leeds today". A visitor in Belfast arrives with NIR, so the page shows "Three working days to Northern Ireland, £6.95". A visitor on a VPN that exits in the Netherlands arrives with NL, so the page receives UNKNOWN and shows the neutral line with the postcode checker. If Aisha ran on Rails behind Cloudflare instead, the same decision would read request.headers['CF-IPCountry'] in a controller.
In the ads: decide who counts as being there
Location targeting in the ad platforms has one setting that decides more than any other, and most accounts never look at it.
In Google Ads, you choose between two options. "Presence or interest", the default and the one Google recommends, reaches people who are in your target area, regularly in it, or who have shown interest in it. "Presence" reaches only people who are in it or regularly in it.7 Interest is worked out from signals such as what people search for and the content they look at about a place.7 Google is candid that all of this is a best effort and that full accuracy is not guaranteed.8
You can target whole countries, regions, cities, postcodes in many countries, or a radius around an address, and Google does not allow a radius under 1 km.8
Meta made the same choice for you. Its targeting reference says the location type ['home', 'recent'] is the only option available, which means people who live in the area or were recently there.9 The options to target only residents, or only people travelling through, are gone. A radius around a city runs from 17 to 80 km, and around a custom point, such as your shop, from 1 to 80 km.9
The setting you want depends on one question. Does your offer need the person to be physically there? An online shop that delivers anywhere in the UK can live with "presence or interest". A boot fitting, a shop event, or a same day delivery promise cannot.
Worked example: the boot fitting campaign
Aisha spends £1,200 a month on a Google Ads campaign for boot fitting at her Leeds shop. It targets a 15 km radius around the shop, left on the default "presence or interest". In a month it gets 800 clicks at £1.50 each.
The location report shows that 220 of those clicks came from people physically outside West Yorkshire, mostly people in London searching for walking boots in Leeds ahead of a trip to the Dales. They will not come in for a fitting. The share of clicks spent outside the area is a simple rate:
Here is the fraction of paid clicks that came from people outside the target area, the numerator counts those clicks, and the denominator counts every click in the same period. It is a ratio of events to opportunities, explained from scratch in Foundations: ratios and rates.
So 27.5% of the clicks, a month, paid for people who could not use the service. Aisha switches the fitting campaign to "presence" and keeps "presence or interest" on her online shop campaigns, where a visitor from London buying a jacket for that trip is exactly who she wants.
For the shop's gear swap evening she runs a Meta ad with a custom location pinned on the shop and a 10 km radius. She accepts that "recently in" will include a few visitors to Leeds, because Meta no longer lets her exclude them, and she says the date and the address in the first line of the ad so nobody travels by mistake.
In the ad text: name the place only where the promise holds
Google can put the place into the ad for you. With location insertion in responsive search ads, you type a brace while writing the ad text, choose location insertion, and Google fills in a city, a state or a country from your campaign's location targeting, with default text for when it cannot.10 One location can go in a headline and up to two in the descriptions.10
It cuts both ways. The ad now claims something about that place, and if the promise is not true there, you have bought a click and a disappointment with the same pound.
Worked example: the headline that nearly misled
Aisha's online campaign targets Leeds, Harrogate, Wakefield and York. Her first draft headline with location insertion reads "Boot fitting in [city]". In Harrogate it would read "Boot fitting in Harrogate". There is no fitting in Harrogate. The shop is in Leeds.
She rewrites it around a promise that is true in every targeted place: "Walking boots to [city] tomorrow", with default text "Walking boots, delivered tomorrow". Next day delivery holds for all four towns, so the place name adds relevance without adding a lie. The fitting gets its own ad, in the Leeds only campaign, where "in Leeds" is simply typed out. And the landing page repeats the promise in the same words, because the ad and the page have to agree, or the visitor feels the switch.
On the landing page: change the facts, keep the pitch
The page is where location earns its money. My rule is that the pitch stays the same everywhere and the facts change. The product, the photos, the reasons to buy are identical for Leeds and Belfast. What changes is the delivery promise, the delivery cost, whether the shop is close enough to visit, and whether an item is in stock where it ships from.
The number to watch is the conversion rate for each place on its own, never the site average. The average is dominated by wherever most of your visitors are, and it will hide a region that is quietly failing.
Here is the conversion rate for one region , the numerator is the number of orders placed by visitors from that region in the period, and the denominator is the number of visitors from that region in the same period. Like the click share above, it rests on Foundations: ratios and rates, and the warning there applies here too: a rate from a small region with few visitors moves around a lot from month to month.
Worked example: the Northern Ireland gap
Aisha splits three months of orders by UK nation, using the delivery address for orders and the IP nation for visitors who did not buy.
The horizontal axis is the visitor's UK nation. The vertical axis is the conversion rate as a percentage, orders divided by visitors for that nation alone. The takeaway: Northern Ireland converts at about a third of England's rate, and Scotland at under three quarters of it.
Take Northern Ireland. In the three months, 4,000 visitors and 36 orders: , so 0.9%. Aisha walks through the checkout as a Belfast customer and finds the leak at once. The page says "Free next day delivery". The checkout then adds £6.95 and three working days. That is the moment people leave.
The fix is not a trick. The product page now shows the true line for Northern Ireland from the first screen, "Three working days to Northern Ireland, £6.95, free over £150", and the checkout says the same. For Scotland, where the IP cannot tell Glasgow from the Highlands, the page shows "Next day to most of Scotland" with the postcode checker right beside it. Aisha does not assume this will work. She tests it, which is the next idea.
Prove it with a holdout, not with a story
Personalisation is a change to the page, so it gets tested like any other change. The cleanest way is a holdout: a random half of the eligible visitors keeps seeing the old page, the other half sees the personalised one, and you compare the two over the same weeks. Comparing this month with last month tells you nothing, because the weather, the season and your ad spend all moved too.
Decide the size of the test before you start, from the smallest lift you would care about. The formula for a test between two conversion rates is:
Here is the number of visitors needed in each half of the test, is 1.96 for a 5% significance level, is 0.84 for 80% power (an 80% chance of spotting a real lift of the size you chose), is the conversion rate you expect without the change and is the rate you hope for with it. The full derivation and what each choice means are in Foundations: sample size.
When the test is over, the result is a relative change from the old rate to the new one:
Here is the relative change, is the conversion rate with personalisation and is the rate without it. Keep it apart from the change in percentage points, which is simply . The difference between the two is explained in Foundations: percentages.
And to tell a real lift from luck, a two proportion test:
Here is the test statistic, and are the two observed conversion rates, is the pooled rate across both halves, and and are the visitors in each half. A further from zero than 1.96 means the gap is significant at the 5% level. The reasoning is in Foundations: hypothesis tests.
Worked example: Aisha's six week test
Northern Ireland alone is too small to test on, so Aisha tests the whole package of location aware delivery lines across every visitor the IP places in a UK nation. Her current rate is 2.0%. She would act on a lift to 2.4%. With 1.96 and 0.84, the first bracket is , and the variance term is . The gap she wants to detect is . Putting it together:
She needs about visitors in each half, 42,164 in all. With 30,000 eligible visitors a month, that is a little over six weeks, so she sets the end date before she starts and does not peek.
At the end, the old page converted 422 of 21,100 visitors (2.0%) and the personalised page 485 of 21,100 (about 2.3%). The relative lift:
So a 15% relative lift, or 0.3 percentage points. Is it luck? The pooled rate is , and then:
With , beyond 1.96, the lift is significant at the 5% level (the two sided p value is about 0.03). It is smaller than the 2.4% she hoped for and still well worth keeping. Notice what she does not do: quote one region's best week as the headline. A big number from one test, in one season, is a story. The holdout is the evidence.
In email: use the address you already have
Email is the easiest place to get location right, and the place it most often goes wrong. People reach for the IP address of the last email open, which might be a work network, a phone on a train or an email provider's own image proxy. Meanwhile the customer's delivery address sits in the order history, exact and given freely.
So in email I personalise from the last delivery address and nothing else. Every email platform with conditional blocks can do this, and if the email is built on your own server, it is a few lines of code.
Worked example: the winter boots email
Aisha sends a winter boots email in November. The line about delivery has to be true for each customer, and her courier's terms set three groups: Northern Ireland (postcodes starting BT), the Highlands and islands postcodes on her courier's surcharge list, and the rest of Great Britain. Her shop runs on Rails, so the email picks the line from the saved address:
class DeliveryPromise
# Postcode areas on the courier's surcharge list (Aisha's own contract)
SLOWER_AREAS = %w[IV HS KW ZE PA PH].freeze
def self.for(postcode)
area = postcode.to_s.upcase[/\A[A-Z]{1,2}/]
return "Three working days to Northern Ireland, £6.95, free over £150" if area == "BT"
return "Two working days to you, free over £75" if SLOWER_AREAS.include?(area)
return "Next day delivery, free over £75" if area
"Free delivery over £75 to most of the UK"
end
end
Step by step. A customer with the postcode LS6 3AB has the area LS, which is not BT and not on the list, so the email says "Next day delivery, free over £75". A customer in Portree with IV51 has the area IV, on the list, so the email says two working days. A customer in Belfast with BT9 gets the Northern Ireland line. A newsletter subscriber who has never ordered has no postcode, so the email falls back to the neutral line rather than guessing from where they opened the last one. Aisha keeps the list in one place, the same file her product page uses, so the email and the page never contradict each other.
The law: what location data means in the UK
None of this is legal advice, and when real risk is in play I check with a solicitor. But three points shape how I build it, and each comes from the regulator or the regulation itself.
First, an IP address is personal data. The ICO points out that the UK GDPR names online identifiers in its definition of personal data, with IP addresses and cookie identifiers among the examples.11 So looking one up, even for a moment, is processing personal data. It needs a lawful basis and a line in your privacy notice, and it is a good reason to use it for one coarse decision and then let it go.
Second, the location rule in the Privacy and Electronic Communications Regulations (PECR) is narrower than people think. Regulation 14 restricts location data processed by providers of public electronic communications networks and services, and allows it only when the person cannot be identified from it or has consented to a value added service.12 The ICO's guidance explains that this means data the network creates about where a device is, such as tracing a phone through mobile masts, and that GPS location from smartphones is not generally covered, although data protection law still applies to it.13 A shop estimating a nation from an IP address header is not a network operator, so regulation 14 is not the rule that governs it. The UK GDPR is.
Third, storing things in the visitor's browser has its own rule. Under PECR, a cookie needs consent unless it is strictly necessary for the service the visitor asked for, and the ICO is clear that cookies which are merely helpful or convenient still need consent.14 A cookie remembering the visitor's guessed country is convenient, not essential. Deciding on each request from the header, as Aisha's proxy does, avoids the question entirely.
Worked example: Aisha's three line check
Before launch, Aisha checks three things. Her privacy notice now says, in plain words, that the site uses the visitor's IP address to estimate which UK nation they are in, so it can show the right delivery information, and that this estimate is not stored. Her proxy writes no cookie and logs no location. And the browser's location prompt never appears, because she never calls the Geolocation API. If she ever wanted a "find my nearest stockist" button, she would trigger that prompt only when the visitor presses the button, never on page load.
For the wider question of how far personalisation should go before it stops feeling helpful, the story in the ethics of personalisation is the one I keep coming back to.
Where to start on Monday
You do not need a personalisation platform for this. You need a short list of facts that genuinely differ by place.
Start with the delivery promise, because it is the fact most likely to be wrong for somebody today. Split your conversion rate by nation or region and look for the one that is quietly failing. Set the ad platforms' location option on purpose, campaign by campaign, asking whether the offer needs the person to be there. Put the place name into an ad only where the promise holds in every place it will be inserted. Use the customer's own postcode wherever you have it and the IP address only for the coarse call. Store nothing you do not need. And test the whole thing with a holdout, sized before you begin.
Selling across borders, with other currencies, languages and tax rules, is a bigger job with its own traps, and I cover it in cross border PPC and scaling internationally. Opening a new city from scratch is in bootstrapping local market growth.