Top Keywords for page url

II want to track top 10 keyword through which visitor landing t my website, While pasting below code to my website pages my website is not loading please help me with right process. code is below:


// This function will call the API to get best keyword for current URL.
// Then it writes the list of best keywords in a HTML list
function DisplayTopKeywords($url = "")
	// Do not spend more than 1 second fetching the data
	@ini_set("default_socket_timeout", $timeout = 1);
	// Get the Keywords data
	$url = empty($url) ? "http://". $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"] : $url;
	$api = "" . urlencode($url);
	$keywords = @json_decode(file_get_contents($api), $assoc = true);
	Common::sendHeader('Content-Type: text/html; charset=utf-8', true);
	if ($keywords === false || isset($keywords["result"])) {
		// DEBUG ONLY: uncomment for troubleshooting an empty output (the URL output reveals the token_auth)
		// echo "Error while fetching the <a href='$api'>Top Keywords from Piwik</a>";

	// Display the list in HTML
	$url = htmlspecialchars($url, ENT_QUOTES);
	$output = "<h2>Top Keywords for <a href='$url'>$url</a></h2><ul>";
	foreach($keywords as $keyword) {
		$output .= "<li>". $keyword . "</li>";
	if (empty($keywords)) { $output .= "Nothing yet..."; }
	$output .= "</ul>";
	echo $output;



your page is not loading because a PHP error occurs. Can you check the PHP error log to find out what exactly goes wrong?