Schedule a call

Ready to scale?

Pick the service you need and book a free Discovery Call.

We've spent millions on Facebook and Google scaling fledgling brands into eCommerce empires. Now it's YOUR turn.

Personalize A Landing Page Dynamically Based on Location [Step-by-Step]

Josh Sturgeon
Last Updated July 12, 2021

If you think about what makes modern marketing so powerful, all roads lead to one thing: personalization.

Facebook ads are powerful because of how precisely we can target an audience. Search ads are powerful because we can target the intent of a potential customer based on what they're searching for in Google.

This high degree of personalization turns advertisers into snipers who find the right people at the right time with the right offer.


Unfortunately, despite having all of this firepower at our disposal, the most common conversion rate killer we see under the hood for new clients is (dun dun dun)...

...Generic landing pages.

We see it all the time. You're targeting left-handed, 31 year-old moms who love chihuahuas with genius, Don Draper-esque ad creative, but driving them to a bland landing page that says "Contact Us." 😴

Personalization is a big topic, so for this post we want to leave you with one simple tactic that can help boost your conversion rates by calling out a user's location in your landing page copy.

Here's the end result: 



Let's get started.

Big picture

We're going to:

  • "Read" a visitors' IP address
  • Look it up in a database to pull state/city names
  • Automatically write that info into the copy of your landing page

You don't have to be a technical whiz. Just follow the directions and you'll do great. 

1. Download this script

We wrote a script that calls on a free service, detects the visitor's IP address, then looks it up in a database to find the city and state names. It also can find things like latitude and longitude, ISP provider, if the user is using a mobile device; which is cool if you wanted to geek out and show a map with a user's current location or get additional information to help with marketing efforts.

The script we wrote acts as a bridge between this service and your landing page, so you can store and use that information in your landing page's content.

NOTE: To use this lookup service, you'll need to create a free account and get an API key which allows 10k free requests per month. API key is not required for testing purposes.

Download Script

2. Add the script to your landing page

We're using Unbounce for this particular tutorial, but any platform will do just fine, provided you have the ability to add Javascript to your pages.

Now that you downloaded the script in the step above, add it to your landing page.



3. Choose where you want the user's city to appear on your page

So remember, we called up to retrieve the city name, we grabbed that information with the script, now we need to tell the script where to put it on your page.

Typically, we'd recommend adding a user's location somewhere in the headline of your page so that it stands out. But you can also get creative, and work it into other places like your CTA button text. The key here is to make it as natural as possible, so the user feels like you created this lander just for them.

In any case, we're going to use a <span> tag to identify where the script should insert the city name.

<h1 class="headline">Want to attend an event near ? <span id="location"> </span></h1>

Name the span id "location".

Let's clarify what's happening here. You're adding this <span> element right within the HTML of a headline. Think of that entire span tag as the city name. In the example above, you can see that we added a contrasting color for it to pop.

4. Check the script to make sure it matches your span id

The script is looking for the id "location" if you've followed these instructions. But if you want to add the city to some other element, you just have to change the "id" in the script to look for that element.

new UB screenshot

5. Test your landing page and adjust formatting

If the IP lookup service can't find a city name in their database, our script will fall back on a state name. So keep that in mind when using the script to avoid any awkward phrasing.

Here is an overview video to help with implementation...



A word on strategy

Just because you can do something doesn't mean you should. Is your offer dependent on location? Then it might make sense to add it dynamically to your landing page. Think: events, job openings, dating, etc.

🤔 Can I optimize my landing page too much? Turns out, yes. →

If a user's location has no bearing on the offer, don't force it. We've seen instances where using this tactic can actually lower conversion rates if it's out of place.

Don't forget that once you're able to capture location, that's where the fun begins. Adding a city name as text to your copy is only one simple application, but the possibilities are endless: pre-populating form fields, customizing a checkout experience, etc.

Now go forth and personalize!

Ready to scale your profits sustainably?

TJ Jones -  CoFounder EmberTribe (1)

T.J. Jones

CoFounder EmberTribe

TJ will help you uncover some of the best growth opportunities for your brand in the First Call.


With over 10 years of experience and 80 million in ad spend under our belts, we know how to guide businesses from fizzle to sizzle.

Seth Bunch-1
"Embertribe has been incredible to work with. Not only are they knowledgeable and the best at their craft but they care about you and your business. Highly recommend!"

Seth Bunch

Founder of Xylem Woodworks

Portrait Lisa FusionBelts
"I tried one company before you guys but you guys are better. And you're all good looking too."

Lisa Vigliorolo

Founder of Fusion Belts

1199958010828334 - Embertribe (Internal Marketing) - 500x500 - SP - 45.01
"EmberTribe has been an incredible ally in our growth strategy. In a short period of time they were able to scale up our ad budget 200%, while decreasing the unit cost for each additional sign up. We see them as an extension of our internal marketing team, which, for a fast growing company, gives us tremendous leverage when building out and scaling new user channels."

Duncan Street

Co-founder, Qeepsake

1199958010828334 - Embertribe (Internal Marketing) - 500x500 - SP - 49.01
“One of the things I love most about working with EmberTribe which has been a standout from working with other companies is that there's a level of ownership that the team has in what we're doing that you really feel like they care."

Cody Barbo

Cofounder, Trust & Will

1199958010828334 - Embertribe (Internal Marketing) - 500x500 - SP - 57.01
"All around great team...The EmberTribe team really answered my technical questions without hesitation...Helped me understand where my business was lacking. It's hard to find companies nowadays that really go above and beyond."

Joey Hettler

Media and Marketing Coordinator at Altis

Grow Faster, Smarter with EmberTribe

If you are stuck on the half a million yearly revenue plateau, you need a growth agency that will get to know your business, audiences, and growth opportunities like the backs of their hands—and let you in on everything they learn. 

No secrets, no bull. Just making sparks fly together.

✅ Focused on revenue

Look elsewhere if you're looking for a new logo or brand identity via 200-page slide decks. Those marketing disciplines have their place, but they're not our focus. We've doubled down on growing sales and injecting our clients with cash flow.

✅ We move fast

The typical agency model moves slowly: endless meetings, thousands of email threads, lots of talk, but little action. EmberTribe is different. We know what it takes to grow fledgling brands into formidable empires: a hell of a lot of execution.

✅ Trusted by the best

We've been recognized by Facebook and Google as one of the top agencies in the world. We're a mentor to startups within Techstars, Y Combinator and regularly consult with programs at MIT and Harvard Business School. Now it's time to add you to our Tribe.

Okay, let's do this!

Book Discovery Call

You May Also Like

These Stories on cro

You May Also Like

These Stories on cro