Coder Social home page Coder Social logo

laravel-analytics's Introduction

Laravel Analytics

Latest Stable Version

Easily collect page view analytics with a beautifully simple to use dashboard.

Laravel Analytics Dashboard

Installation

Install the package:

composer require andreaselia/analytics

Publish the config file and assets:

php artisan vendor:publish --provider="AndreasElia\Analytics\AnalyticsServiceProvider"

Don't forget to run the migrations:

php artisan migrate

You can add the page view middleware to a specific route group, e.g. web.php like so:

Route::middleware('analytics')->group(function () {
    // ...
});

Or add the page view to all middlewares/on an application level like so:

// app/Http/Kernel.php

protected $middleware = [
    // ...
    \AndreasElia\Analytics\Http\Middleware\Analytics::class,
];

Configuration

Changing how session_id is determined

By default, session_id in the page_views table is filled with the session ID of the current request. However, in certain scenarios (for example, for API and other requests not using cookies), the session is unavailable.

In these cases, you can create a custom session ID provider: create a class that implements the AndreasElia\Analytics\Contracts\SessionProvider interface and set its name as the provider option in the analytics.php config file. The configured class object is resolved from the container, therefore, dependency injection can be used via the __constructor.

One example of a custom way to generate the session ID in cookie-less environment is to hash IP address + User Agent + some other headers from the request.

Feel free to take a look at AndreasElia\Analytics\RequestSessionProvider for an example of implementing the SessionProvider interface.

Contributing

You're more than welcome to submit a pull request, or if you're not feeling up to it - create an issue so someone else can pick it up.

laravel-analytics's People

Contributors

andreaselia avatar imanghafoori1 avatar justrau avatar muhammadmp97 avatar tomirons avatar umfi avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.