Skip to content

Instantly share code, notes, and snippets.

@stengland
Last active May 1, 2024 11:34
Show Gist options
  • Save stengland/e3a88bc619fea3432b30ec5d2884f62c to your computer and use it in GitHub Desktop.
Save stengland/e3a88bc619fea3432b30ec5d2884f62c to your computer and use it in GitHub Desktop.
Easy redirects or geo data using https://freegeoip.net, can be used on google tag manager.
<script>
function geo(data) {
if (data.country_code == 'IE') {
window.location = "/ie" + window.location.search;
} else {
dataLayer.push(data);
}
}
</script>
<script src="https://freegeoip.net/json/?callback=geo"></script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment