 <p>The answer of Eike pointed me in the right direction, therefore +1 for his answer, but I had to use cURL instead of fopen().</p> <p>My complete working solution:</p> <pre><code>&lt;?php $curl_handle=curl_init(); curl_setopt($curl_handle, CURLOPT_URL,'http://www.google-analytics.com/collect/v=1&amp;tid=UA-xxxxxxx-1&amp;cid=555&amp;t=pageview&amp;dp=%2Fgeoip.php'); curl_setopt($curl_handle, CURLOPT_CONNECTTIMEOUT, 2); curl_setopt($curl_handle, CURLOPT_RETURNTRANSFER, 1); curl_setopt($curl_handle, CURLOPT_USERAGENT, 'Geoip tracker'); $query = curl_exec($curl_handle); curl_close($curl_handle); $arr = array('country' =&gt; 'United States', 'city' =&gt; 'New York'); if(isset ($_GET['jsonp'])) { echo $_GET['jsonp'] . '(' . json_encode($arr) . ')'; } else { echo json_encode($arr); } ?&gt; </code></pre>