Yii2 widget for displaying Google AdSense banners. This widget provides a convenient method for displaying Adsense banners in Yii2 templates.
This widget also makes it easy to disable Adsense, which can be useful for development. When disabled, this widget shows a dummy banner with the actual banner size and an indication whether this is a valid banner size for AdSense.
Requirements ¶
- Yii2
- Google AdSense account
Installation ¶
Install with composer:
composer require geertw/yii2-adsense
Usage ¶
Configure Yii params like follows:
return [
'adsense' => [
'client' => 'ca-pub-1234567890123456',
'slot' => '1234567890',
'enabled' => true,
],
];
Use it in your views like this:
<div style="width: 728px; height: 90px">
<?= \geertw\Yii2\Adsense\AdsenseWidget::widget(); ?>
</div>
See the project page for more documentation.
If you have any questions, please ask in the forum instead.
Signup or Login in order to comment.