Automatic Language Redirection in HighLevel
Learn how to automatically redirect users to their preferred language page using JavaScript and browser language detection.
Are you using multiple languages for your HighLevel pages? Then this video is for you! You’re probably having something like this: a page where the user can switch the languages just by clicking a button, and then you have the different languages on different pages. But the user already set his language in the browser, so why can we not do it automatically?
I’m going to show you how you can do this.
Overview
This solution automatically detects the user’s browser language and redirects them to the appropriate language version of your website. Instead of requiring manual language selection, users are automatically taken to their preferred language page.
Implementation Steps
Step 1: Set Up Your URLs
First, we need to define the URLs for each language page. In your HighLevel page builder, go to the tracking code section and insert this JavaScript:
// set your URLs for each language
const urls = {
'es': 'https://demo.web.de.com/es',
'de': 'https://demo.web.de.com/de',
};
Important Notes:
- Replace the placeholder URLs with your actual domain names and page links
'es'
represents Spanish pages'de'
represents German pages- You can add as many languages as you need by simply adding more comma-separated entries
Step 2: Detect Browser Language
Next, we get the user’s browser language and convert it to a short format:
// gets the users language from browser settings
var userLang = navigator.language || navigator.userLanguage;
var shortLang = userLang.slice(0, 2);
How it works:
navigator.language
gets the primary browser languagenavigator.userLanguage
is a fallback for older browsersslice(0, 2)
extracts just the first two characters (e.g., “en” from “en-US”, “de” from “de-DE”)
Step 3: Implement Redirection Logic
Finally, we loop through all available languages and redirect if a match is found:
// redirect if available
for (lang in urls){
if (shortLang == lang) {
window.location.href = urls[lang];
}
}
The complete script:
<script>
// set your URLs for each language
const urls = {
'es': 'https://demo.web.de.com/es',
'de': 'https://demo.web.de.com/de',
};
// gets the users language from browser settings
var userLang = navigator.language || navigator.userLanguage;
var shortLang = userLang.slice(0, 2);
// redirect if available
for (lang in urls){
if (shortLang == lang) {
window.location.href = urls[lang];
}
}
</script>
How to Implement in HighLevel
- Open your main page in the HighLevel page builder
- Go to tracking code section
- Insert the complete script above
- Update the URLs to match your actual domain and page structure
- Save and test your implementation
Testing Your Implementation
To verify the redirection works correctly:
- Test with English browser: Should not redirect (stays on main page)
- Test with German browser: Should automatically redirect to German page
- Test with Spanish browser: Should automatically redirect to Spanish page
Customization Options
Adding More Languages
You can easily extend this to support additional languages:
const urls = {
'es': 'https://yoursite.com/es',
'de': 'https://yoursite.com/de',
'fr': 'https://yoursite.com/fr',
'it': 'https://yoursite.com/it',
'pt': 'https://yoursite.com/pt'
};
Fallback Language
You can add a fallback for unsupported languages:
// redirect if available
var redirected = false;
for (lang in urls){
if (shortLang == lang) {
window.location.href = urls[lang];
redirected = true;
break;
}
}
// If no language match found, redirect to default
if (!redirected) {
window.location.href = 'https://yoursite.com/en'; // Default English page
}
Browser Compatibility
This solution works with:
- ✅ Chrome, Firefox, Safari, Edge (modern browsers)
- ✅ Mobile browsers
- ✅ Older browsers (using
navigator.userLanguage
fallback)
Benefits
- Improved User Experience: Users automatically see content in their preferred language
- Reduced Bounce Rate: No need for manual language selection
- Professional Appearance: Shows attention to international users
- Easy Implementation: Simple JavaScript code that works immediately
Common Use Cases
- E-commerce websites with international customers
- Service businesses operating in multiple countries
- Educational platforms with multilingual content
- Corporate websites with global presence
Troubleshooting
If redirection isn’t working:
- Check browser language settings - ensure the browser is set to a supported language
- Verify URLs - make sure your language page URLs are correct and accessible
- Clear browser cache - sometimes cached pages can interfere with redirection
- Check console errors - look for JavaScript errors in browser developer tools
Final Result
This is how you automatically redirect users to a multilingual page by the browser language. The solution is simple, effective, and works immediately once implemented.
I hope you find this video useful! See you in the next one.
Resources
- HighLevel Platform: Official Website
- JavaScript Language Detection: MDN Navigator.language
- Browser Language Codes: ISO 639-1 Language Codes