我是否可以在不破坏Google分析跟踪的情

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:

  • Stop them adding a product to basket
  • On the product page hide any 'Add to Cart' button and replace it with some simple 'This product is not available in your country' text.

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.