Google ads


Can you please point me in the right direction. I’m new to Yii and i would like to display Google adverts on my website. I’ve got a google client # and channel #.


Hi welcome to the forum.

You can create a widget. Like this:

class AdSenseWidget extends CWidget


   public $clientId;

   public $channelId;

   public function run()


      // output the adsense code here

      // like...

      echo "{$this->clientId}&channelId={$this->channelId}";



Then to display the widget within a view:

$this->widget('AdSenseWidget', array('clientId' => 123, 'channelId' => 456));

Take a look at the widget doc or use the site search for more info.


Many Thanks for your reply. I’ll try that!