Yii2 Anonymous User
A Yii2 extension for tracking anonymous users., (*1)
Installation
The preferred way to install this extension is through composer., (*2)
Either run, (*3)
php composer.phar require --prefer-dist simonmesmith/yii2-googleadsense "*"
or add, (*4)
"simonmesmith/yii2-googleadsense": "*"
to the require section of your composer.json
file., (*5)
Usage
Once the extension is installed :, (*6)
- Run /data/anonymoususer.sql to set up the required table. Note that it currently creates the table with a tbl_ prefix. Also note that I've yet to experiment with Yii2 migrations for setting up database objects, hence why this just uses a .sql file.
- Add the following to your main.php configuration file:
'components' => [
...
'anonymousUser' => [
'class' => 'simonmesmith\anonymoususer\AnonymousUserComponent',
],
...
- Use the component when you need to track an anonymous user as follows:
Yii::$app->anonymousUser->id