Commit 13d7253d authored by Avris's avatar Avris

docs

parent 1b40de6f
......@@ -3,13 +3,19 @@
This is a module for [Micrus framework](https://micrus.avris.it)
that adds a really basic helper for Google Analytics.
To install this module, open the file `app/Config/modules.yml` and add:
### Installation
- Avris\Micrus\GoogleAnalytics\GoogleAnalyticsModule
In your `App\App:registerModules` register the module:
Then run:
yield new \Avris\Micrus\GoogleAnalytics\GoogleAnalyticsModule;
then run:
composer require avris/micrus-ga
You will be asked for a GA Tracking-ID and it will be saved in the `.env` file.
If you don't provide any (for instance in a testing environment),
this service will not fail, it will just do nothing.
### Usage ###
......@@ -17,14 +23,20 @@ To include a tracking code in your template, just write before the closing `</bo
{{ googleAnaytics() }}
To report a visit from the server side, you can include this code:
To report a visit from the server side, you can run this code:
$this->get('googleAnalytics')->collect($this->getRequest());
public function generateImageAction(RequestInterface $request, GoogleAnalytics $ga)
{
// ...
$ga->collect($request);
// ...
}
Note that if you don't provide any Tracking-ID in your `parameters.yml`,
no action will be taken in any of those two cases.
For performance, that data will be sent during request termination
(so in the background, after the response has already been sent).
You can force the service to send the data right away with `$ga->collect($request, false)`.
### Copyright ###
### Copyright
* **Author:** Andrzej Prusinowski [(Avris.it)](https://avris.it)
* **Author:** Andre Prusinowski [(Avris.it)](https://avris.it)
* **Licence:** [MIT](https://mit.avris.it)
Avris\Micrus\GoogleAnalytics\:
dir: '%MODULE_DIR%/src/'
Avris\Micrus\GoogleAnalytics\GoogleAnalytics:
public: true
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment