I’ve got a little php script setup to randomly switch between three ads. One of these ads is global but the other two are for amazon.com and amazon.co.uk and I was thinking it might be better to ensure that amazon.co.uk only gets shown to visitors from the UK. Is this a doable check in php? What I have right now is this:
<?php
$ad[] =
'AD 1 - Global'
;
$ad[] =
'AD 2 - Amazon.com - Should be Global except UK'
;
$ad[] =
'AD 3 - Amazon.co.uk - Should be UK only'
;
srand ((double) microtime() * 9999999);
$random_number = rand(0,count($ad)-1);
echo ($ad[$random_number]);
?>
I’d imagine the first step would be to randomize the selection between AD 1 and AD 2 + AD 3. And if it hits AD 2 + AD 3, make a selection based on location.