2017 © Pedro Peláez
 

library laravel-server-side-ga

A simple Laravel package that allows the sending of Google Analytics events from the server side

image

stelianandrei/laravel-server-side-ga

A simple Laravel package that allows the sending of Google Analytics events from the server side

  • Tuesday, June 12, 2018
  • by StelianAndrei
  • Repository
  • 1 Watchers
  • 0 Stars
  • 3 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 6 Versions
  • 0 % Grown

The README.md

Laravel Server Side Google Analytics

This is a simple package that allows you to track Google Analytics page views and events from your Laravel application., (*1)

It was created because I needed a simple way to track these when certain actions occured server-side or when specific actions were triggered from the frontend and I din't want to mingle the JavaScript logic with the tracking part., (*2)

Installation

First thing you need to do is require the package using composer., (*3)

composer require stelianandrei/laravel-server-side-ga

Then you need to add the service provider to your config/app.php file under the Package Service Providers section:, (*4)

  StelianAndrei\LaravelServerSideGA\AnalyticsServiceProvider::class,

Also add the Analytics facade to the aliases array in the same file:, (*5)

  'Analytics' => StelianAndrei\LaravelServerSideGA\AnalyticsFacade::class,

Last thing you need to do is publish the configuration for this package. In order to do that all you need to do it run the following command:, (*6)

php artisan vendor:publish --provider="StelianAndrei\LaravelServerSideGA\AnalyticsServiceProvider"

That will create a configuation file for this package at config/analytics.php where you need to enter the property code you are using for tracking events and page views. You can either keep it here or define the ANALYTICS_TRACKING_ID property in your .env file., (*7)

Tracking page views

To track page views, use it as follows:, (*8)

Analytics::trackPage($page, $title, $hitType)

Where:, (*9)

  • $page - (optional) the url of the page you are tracking (eg: /about)
  • $title - (optional) the title of the page you are tracking (eg: About us)
  • $hitType - (optional) the type of hit you are sending (defaults to pageview)

Tracking events

To track an event, use it as follows:, (*10)

Analytics::trackEvent($category, $action, $label = null, $value = null)

Where:, (*11)

  • $category - the category of the event (eg: Account creation)
  • $action - the action you're tracking (eg: Click button)
  • $label - (optional) the label for the event (eg: Recover password)
  • $value - (optional) an optional value for the event

The Versions

12/06 2018

dev-master

9999999-dev https://github.com/StelianAndrei/laravel-server-side-ga

A simple Laravel package that allows the sending of Google Analytics events from the server side

  Sources   Download

MIT

The Requires

 

by Stelian-Andrei Adumitroaei

laravel analytics server-side

12/06 2018

dev-develop

dev-develop https://github.com/StelianAndrei/laravel-server-side-ga

A simple Laravel package that allows the sending of Google Analytics events from the server side

  Sources   Download

MIT

The Requires

 

by Stelian-Andrei Adumitroaei

laravel analytics server-side

12/06 2018

1.0.0

1.0.0.0 https://github.com/StelianAndrei/laravel-server-side-ga

A simple Laravel package that allows the sending of Google Analytics events from the server side

  Sources   Download

MIT

The Requires

 

by Stelian-Andrei Adumitroaei

laravel analytics server-side

12/06 2018

0.1.2

0.1.2.0 https://github.com/StelianAndrei/laravel-server-side-ga

A simple Laravel package that allows the sending of Google Analytics events from the server side

  Sources   Download

MIT

The Requires

 

by Stelian-Andrei Adumitroaei

laravel analytics server-side

12/06 2018

0.1.1

0.1.1.0 https://github.com/StelianAndrei/laravel-server-side-ga

A simple Laravel package that allows the sending of Google Analytics events from the server side

  Sources   Download

MIT

The Requires

 

by Stelian-Andrei Adumitroaei

laravel analytics server-side

12/06 2018

0.1.0

0.1.0.0 https://github.com/StelianAndrei/laravel-server-side-ga

A simple Laravel package that allows the sending of Google Analytics events from the server side

  Sources   Download

MIT

The Requires

 

by Stelian-Andrei Adumitroaei

laravel analytics server-side