Skip to main content
Geo-fencing lets you deliver different content, offers, or experiences to visitors based on their geographic location. This is useful for compliance (restricting access to visitors in certain regions), localization (showing region-specific pricing or language), and targeted marketing (presenting location-relevant promotions).

What geo-fencing can do

Within HoopAI funnels and websites, you can use geography-based logic to:
  • Redirect visitors from specific countries or regions to a different page or URL
  • Show or hide sections of a page based on visitor location
  • Display location-specific offers, pricing, or copy
  • Block access to a funnel from restricted regions
  • Route visitors to a localized version of your funnel

How location detection works

HoopAI detects visitor location using IP geolocation. When a visitor loads a funnel page, their IP address is used to determine their approximate location — typically accurate to the country and often to the region or city level. Visitors using VPNs may appear to be located in a different country than their physical location.

Geo-based redirects using custom JavaScript

The most flexible approach to geo-fencing in HoopAI is to add a JavaScript snippet to the page or funnel-level tracking code that checks the visitor’s location and takes action accordingly.

Redirect visitors from a specific country

Paste this in the Head Tracking Code field (funnel-level) or page-level tracking code. Replace US with the ISO 3166-1 alpha-2 country code for the country you want to target and update the redirect URL:
<script>
fetch('https://ipapi.co/json/')
  .then(response => response.json())
  .then(data => {
    if (data.country_code === 'US') {
      // Visitor is in the United States — redirect to US-specific funnel
      window.location.href = 'https://yourdomain.com/us-offer';
    }
  });
</script>

Show content only for visitors in a specific region

<script>
fetch('https://ipapi.co/json/')
  .then(response => response.json())
  .then(data => {
    // Show a region-specific element for visitors in California
    if (data.region === 'California') {
      document.querySelector('#ca-specific-offer').style.display = 'block';
    }
  });
</script>

Block visitors from specific countries

<script>
fetch('https://ipapi.co/json/')
  .then(response => response.json())
  .then(data => {
    const blockedCountries = ['XX', 'YY']; // Replace with country codes to block
    if (blockedCountries.includes(data.country_code)) {
      window.location.href = '/not-available'; // Redirect to a "not available" page
    }
  });
</script>

Common geo-fencing use cases

Some products, offers, and services cannot legally be offered in certain countries or regions. Use geo-based redirects to send visitors from restricted regions to a compliance page explaining that the offer is not available in their location.

Currency and pricing

Display different pricing pages for different regions. Route visitors from the EU to a EUR-priced version of your funnel and visitors from the UK to a GBP-priced version.

Language localization

If you maintain separate versions of a funnel in different languages, use geo-fencing to automatically route visitors to the version that matches their country’s primary language.

Regional promotions

Run country-specific promotions without creating entirely separate funnels. Show a local phone number, local testimonials, or a region-specific bonus offer to visitors from that location.

Geo-fencing limitations

  • VPN users: Visitors using VPNs will appear to be in the country of the VPN server, not their actual location. Geo-fencing cannot reliably block or target VPN users.
  • IP accuracy: IP geolocation is accurate at the country level in most cases. City and region-level accuracy is lower and varies by provider.
  • Load time: Fetching geolocation data from a third-party API adds a small amount of latency. For performance-critical pages, consider pre-loading or caching geolocation data.
  • Privacy considerations: Collecting and processing geolocation data may be subject to GDPR, CCPA, or other privacy regulations. Disclose location-based processing in your privacy policy.
For simple country-based redirects, use a lightweight geolocation API like ipapi.co or ip-api.com. For more sophisticated geo-routing with better performance and accuracy, consider a dedicated service such as Cloudflare Workers or a CDN with geo-routing capabilities.
Geo-fencing based on custom JavaScript is not a built-in drag-and-drop feature in HoopAI — it requires adding JavaScript to your tracking code or a custom code element. If JavaScript is disabled in the visitor’s browser, geo-fencing logic will not execute.
Last modified on March 5, 2026