Hotjar for Yii2
This extension provides easy way to add Hotjar tracking in your Yii2 application., (*1)
Based on https://github.com/cybercog/yii2-google-analytics, (*2)
Installation
The preferred way to install this extension is through composer., (*3)
Either run, (*4)
$ php composer.phar require thiagotalma/yii2-hotjar "*
or add, (*5)
"thiagotalma/yii2-hotjar": "*"
to the require section of your composer.json
file., (*6)
Usage
In your /views/layouts/main.php
add, (*7)
use talma\hotjar\widgets\HotjarTracking;
Then before </head>
add following code, (*8)
<?= HotjarTracking::widget(
[
'trackingId' => 'XXXXXXXX'
]
) ?>
Advanced usage
If you need the output without script
tag to combined with registerJs
or registerJsFile
as renderPartial
to add dependency or positioning configuration, you can use omitScriptTag true to disable script
tag, example:, (*9)
<?= $this->registerJs(
HotjarTracking::widget([
'trackingId' => 'XXXXXXXX',
'omitScriptTag' => true
]), \yii\web\View::POS_END
); ?>