Yii2 Widget for Google Analytics

v1.0.0 2019-11-27 08:37 UTC

This package is auto-updated.

Last update: 2020-06-27 10:16:56 UTC


Yii2 Widget for Google Analytics


The preferred way to install this extension is through composer.

Either run

php composer.phar require --prefer-dist tomlutzenberger/yii2-googleanalytics "*"

or add

"tomlutzenberger/yii2-googleanalytics": "*"

to the require section of your composer.json file.


Once the extension is installed, simply use it in your code by:

<?= \TomLutzenberger\GoogleAnalytics\GoogleAnalytics::widget() ?>

You can either add the ID of your container to the params.php

return [
    // ...
    'gaId' => YII_ENV_PROD ? 'UA-1234567-01' : '',

or pass it directly to the widget:

<?= \TomLutzenberger\GoogleAnalytics\GoogleAnalytics::widget([
    'gaId' => 'UA-1234567-01'
]) ?>


This package is published under the MIT License and can be used for any commercial and personal projects.