Add GeoSwap to any WordPress site in under 2 minutes
Want to redirect visitors by country, show different content by location, or display geo-targeted popups on your WordPress site? GeoSwap makes it simple. One script tag is all it takes.
No plugin needed — one script tag is all it takes
Works with every theme and page builder
Zero impact on your WordPress performance
Most WordPress geo-targeting tools come as plugins. That sounds convenient, but plugins create real problems for site performance and reliability.
Every plugin runs PHP code on every page load. Geo-targeting plugins query databases, call external APIs, and add processing time to your server response. That slows down your site for everyone, not just the visitors being targeted.
WordPress caching plugins (WP Rocket, LiteSpeed Cache, Cloudflare APO) serve static HTML to make your site fast. Geo-targeting plugins need to serve different content per visitor — which means they disable caching or bypass it. You lose the speed gains you worked hard to set up.
Every plugin is another thing to update, another potential security vulnerability, and another point of failure when WordPress or your theme updates. One bad plugin update can break your entire site.
GeoSwap is different
The GeoSwap script loads from our global CDN — not from your WordPress server. It adds zero PHP overhead, works perfectly with every caching plugin, and never needs updating on your end.
Pick whichever method is most comfortable for you. All three produce the same result.
This is the quickest way to get started. You paste the script directly into your theme's header file.
In your WordPress admin, go to Appearance → Theme File Editor.
In the file list on the right, click header.php. This file controls the <head> section of every page on your site.
Find the closing </head> tag and paste the GeoSwap script just above it.
Click Update File. GeoSwap is now active on every page of your WordPress site.
<!-- Add before </head> in header.php -->
<script
src="https://cdn.geoswap.co/geoswap.js"
data-account="YOUR_ACCOUNT_ID"
defer
></script>
</head>Theme updates will overwrite this
If you update your WordPress theme, the header.php file gets replaced and you will need to re-add the script. Use Option B or C below if you want something that survives theme updates.
Adding the script via functions.php is the WordPress-recommended way to load external scripts. If you use a child theme, this survives parent theme updates.
Go to Appearance → Theme File Editor and open functions.php. Add this code at the bottom of the file:
function geoswap_enqueue_script() {
wp_enqueue_script(
'geoswap-geo',
'https://cdn.geoswap.co/geoswap.js',
array(),
null,
false // Load in <head>, not footer
);
wp_script_add_data('geoswap-geo', 'defer', true);
}
add_action('wp_enqueue_scripts', 'geoswap_enqueue_script');
// Add the data-account attribute to the script tag
function geoswap_script_attributes($tag, $handle, $src) {
if ('geoswap-geo' !== $handle) return $tag;
return str_replace(
' src=',
' data-account="YOUR_ACCOUNT_ID" src=',
$tag
);
}
add_filter('script_loader_tag', 'geoswap_script_attributes', 10, 3);Replace YOUR_ACCOUNT_ID with your actual Account ID from the GeoSwap dashboard.
If you are not comfortable editing theme files, use a free plugin like WPCode or Insert Headers and Footers by WPBeginner. These plugins give you a simple text box where you paste the script — no file editing required.
Go to Plugins → Add New and search for "WPCode". Install and activate it.
Go to Code Snippets → Header & Footer. Paste the GeoSwap script into the Header section.
Click Save Changes. The script is now on every page and survives theme updates.
<script src="https://cdn.geoswap.co/geoswap.js" data-account="YOUR_ACCOUNT_ID" defer></script>GeoSwap works with every WordPress theme, page builder, and e-commerce plugin. No special configuration needed.
Because the GeoSwap script is loaded from our CDN (not from your WordPress server), it works perfectly alongside every WordPress caching plugin. Your cache stays intact. Your pages stay fast.
Unlike WordPress geo-targeting plugins that need to bypass page cache to serve different content, GeoSwap handles geo logic on the client side after the cached page loads. Your cache hit rate stays at 100%.
After adding the script, confirm everything is working:
Open your WordPress site in a browser.
Go to Settings → Install in your GeoSwap dashboard.
Click Verify Installation. A green checkmark means you are live.
You can also verify manually: open your browser's Developer Tools (F12), go to the Network tab, and look for geoswap.js loading with a 200 status.
Use the defer attribute (included by default) for best page load performance. It tells the browser to load the script without blocking page rendering.
Don't put the script in the footer. GeoSwap needs to load early to execute redirect rules before the visitor sees the page. The <head> section is the right place.
If you use a child theme, add the functions.php snippet to the child theme's functions.php. This way your changes survive parent theme updates.
If you use WooCommerce with Geo Currencies, add the data-geoswap-price attribute to your price elements so GeoSwap can find and convert them.
Clear your WordPress cache after adding the script. Most caching plugins will serve the old version of your pages until you purge the cache.
Create your first geo redirect or content personalization rule.