Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/xruff/googleanalytics
Google Analytics component for Nette
https://github.com/xruff/googleanalytics
google-analytics nette nette-component
Last synced: 26 days ago
JSON representation
Google Analytics component for Nette
- Host: GitHub
- URL: https://github.com/xruff/googleanalytics
- Owner: XRuff
- Created: 2017-04-27T21:17:05.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2023-01-13T11:19:44.000Z (almost 2 years ago)
- Last Synced: 2024-11-24T23:50:41.539Z (about 2 months ago)
- Topics: google-analytics, nette, nette-component
- Language: PHP
- Size: 11.7 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
Google Analytics component for Nette Framework application
======Requirements
------------Package requires PHP 5.6 or higher
- [nette/security](https://github.com/nette/security)
- [nette/application](https://github.com/nette/application)Installation
------------The best way to install XRuff/GoogleAnalytics is using [Composer](http://getcomposer.org/):
```sh
$ composer require xruff/googleanalytics
```Documentation
------------Configuration in config.neon. Both parameters are optional.
If parameter `code` is missing, GA code will not be rendered in template. If parameter `user` is missing, default settings will be used - value `on`. If paramter `user` is `on` and user is logged in, google analytics code will contain directive `ga('set', 'userId', {$user->id});`
```yml
extensions:
googleAnalytics: XRuff\App\UI\Components\DI\GoogleAnalyticsExtensiongoogleAnalytics:
code: UA-123456789-1
user: on # on/off - display user ID if user is logged in
```Base presenter:
```php
use XRuff\App\UI\Components\IGoogleAnalyticsControlFactory;abstract class BasePresenter extends Nette\Application\UI\Presenter
{
/** @var IGoogleAnalyticsControlFactory $googleAnalyticsControlFactory @inject */
public $googleAnalyticsControlFactory;protected function createComponentGoogleAnalytics()
{
return $this->googleAnalyticsControlFactory->create();
}
}
```@layout.latte:
```smarty
...{control googleAnalytics}
...
```You can invoke parameters into control in latte template. 1st parameter is GA code. 2nd parameter should be boolean and manage displaying GA directive for user's session - `ga('set', 'userId', {$user->id});`. Both parameters are optioanl.
```smarty
...{control googleAnalytics 'UA-123456789-2', false}
...
```-----
Repository [https://github.com/XRuff/GoogleAnalytics](https://github.com/XRuff/GoogleAnalytics).