Download the PHP package jamesfairhurst/laravel-google-analytics-pageviews without Composer
On this page you can find all versions of the php package jamesfairhurst/laravel-google-analytics-pageviews. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download jamesfairhurst/laravel-google-analytics-pageviews
More information about jamesfairhurst/laravel-google-analytics-pageviews
Files in jamesfairhurst/laravel-google-analytics-pageviews
Package laravel-google-analytics-pageviews
Short Description Track pageviews server side using the Google Analytics Measurement Protocol.
License MIT
Homepage https://github.com/jamesfairhurst/laravel-google-analytics-pageviews
Informations about the package laravel-google-analytics-pageviews
Track Pageviews Server Side using Google Analytics
Don't want nasty tricksy Google Analytics JS tracking code on your site but still want to have some idea of pageviews? This package uses Google's Measurement Protocol to record basic pageviews on your site. It uses a small chunk of Javascript to post page data via Ajax on window load which will get sent to Google using Guzzle.
Currently available for Laravel 5.7 & 5.8, looking into older versions.
Installation
You can install the package via composer:
Optionally, you can publish the config file of the package.
The config file looks like:
Usage
Add the Google Analytics Property Tracking ID to your .env
file
Next, add the @pageviews
blade directive to any page you wish to track or in a layouts file to track all pages e.g.
@pageviews
will add a small chunk of Javascript that will send a POST
XMLHttpRequest
request on window.load
to a package controller action that will record the pageview using Google's Measurement Protocol.
You can also explicitly disable tracking by adding PAGEVIEWS_ENABLED=false
to your .env
file which is useful to stop tracking locally.
Contributing
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.