rdehnhardt / laravel-analytics by rdehnhardt

Analytcs for Laravel
448
23
3
Package Data
Maintainer Username: rdehnhardt
Maintainer Contact: renatotkd@gmail.com (Renato Dehnhardt)
Package Create Date: 2015-07-24
Package Last Update: 2019-11-15
Language: PHP
License: MIT
Last Refreshed: 2024-11-19 03:10:28
Package Statistics
Total Downloads: 448
Monthly Downloads: 2
Daily Downloads: 0
Total Stars: 23
Total Watchers: 3
Total Forks: 6
Total Open Issues: 0

Laravel Analytcs

How to install

composer require baconfy/laravel-analytics

config/app.php

...
'providers' => [
    Rdehnhardt\Analytics\Providers\AnalyticsServiceProvider::class,
],
...

Execute

php artisan migrate

php artisan vendor:publish

In html pages

<script>
    var _bc = _bc || [];

    (function () {
        var bc = document.createElement('script');
        bc.src = '/analytics.js';
        bc.type = 'text/javascript';
        bc.async = true;
        var s = document.getElementsByTagName('script')[0];
        s.parentNode.insertBefore(bc, s);
    })();
</script>

Route

/analytics/visits/Y-m-d/Y-m-d

Ex:

/analytics/visits/2015-07-27/2015-07-27

show

Hora,Visitas,Únicas
00:00,1,1
01:00,2,1
02:00,3,1
03:00,4,1
04:00,5,1
05:00,7,1
06:00,1,1
07:00,4,1
08:00,6,1
09:00,2,1
10:00,3,1
11:00,3,1
12:00,3,1
13:00,15,1
14:00,15,1

Using HighCharts

<div id="container" style="min-width: 310bc; height: 400bc; margin: 0 auto"></div>

<script>
    $(function () {
        $.ajax({url: "/analytics/visits/2015-07-27/2015-07-27"}).done(function (csv) {
            $('#container').highcharts({
                data: {csv: csv},
                title: {text: 'Relatório de visitas'},
                subtitle: {text: 'Source: Analytics'},
                tooltip: {shared: true},
                yAxis: { allowDecimals: false },
                plotOptions: {column: {stacking: 'normal'}}
            });
        });
    });
</script>

alt text