I really need to stop USA based visitors proceeding to buy products on our UK only website. We are getting a lot of fraud from USA based IP's. I have this nice solution ready to go live, but will it stop Google Analytics and any other USA based tracking scripts working on my website? Does anyone have a better solution?
// Cut non UK countries out of going any further:
$ip = $_SERVER['REMOTE_ADDR'];
$country = getCountryFromIP($ip, " NamE ");
if (strtolower($country) == "united states") {
$pageOutput = file_get_contents("country.exclusion.html");
$pageOutput = str_replace("<quote:site-wide-footer-tracking.html>", file_get_contents("../static-includes/site-wide-footer-tracking.php"), $pageOutput );
I think a better way of doing this would be to prevent US based users from completing certain actions:
This will prevent them from ever purchasing a product but still make sure Google and other US based entities can browse your site without restriction.