public function getHeader()
	{
		if (!$this->isAsync())
		{
			// Synchronous code is included only in the body
			return '';
		}

		if (!$this->getOption('code'))
		{
			throw new UnexpectedValueException('A Google Analytics tracking code is required.');
		}

		$code = $this->getOption('code');

		$output = '<script type="text/javascript">';
		$output .= 'var _gaq = _gaq || [];';
		$output .= "_gaq.push(['_setAccount', '{$code}']);";

		foreach ($this->listCalls() as $call)
		{
			$output .= $this->createCall($call['name'], $call['params']);
		}

		$output .= '_gaq.push(["_trackPageview"]);';
		$output .= '</script>';

		return $output;
	}
public function getHeader()
	{
		if (!$this->isAsync())
		{
			// Synchronous code is included only in the body
			return '';
		}

		if (!$this->getOption('code'))
		{
			throw new UnexpectedValueException('A Google Analytics tracking code is required.');
		}

		$code = $this->getOption('code');

		$output = '<script type="text/javascript">';
		$output .= 'var _gaq = _gaq || [];';
		$output .= "_gaq.push(['_setAccount', '{$code}']);";

		foreach ($this->listCalls() as $call)
		{
			$output .= $this->createCall($call['name'], $call['params']);
		}

		$output .= '_gaq.push(["_trackPageview"]);';
		$output .= '</script>';

		return $output;
	}
public function getHeader ( ) { if ( ! $ this -> isAsync ( ) ) { // Synchronous code is included only in the body return '' ; } if ( ! $ this -> getOption ( 'code' ) ) { throw new UnexpectedValueException ( 'A Google Analytics tracking code is required.' ) ; } $ code = $ this -> getOption ( 'code' ) ; $ output = '<script type="text/javascript">' ; $ output .= 'var _gaq = _gaq || [];' ; $ output .= "_gaq.push(['_setAccount', '{$code}']);" ; foreach ( $ this -> listCalls ( ) as $ call ) { $ output .= $ this -> createCall ( $ call [ 'name' ] , $ call [ 'params' ] ) ; } $ output .= '_gaq.push(["_trackPageview"]);' ; $ output .= '</script>' ; return $ output ; }
Get code to load Google Analytics javascript

@return  string  Javascript code

@since   1.0
@throws  UnexpectedValueException
Get code to load Google Analytics javascript