PikoPong
  • Web Dev
  • Hack
  • Database
  • Big Data
  • AWS
  • Linux
No Result
View All Result
PikoPong
  • Web Dev
  • Hack
  • Database
  • Big Data
  • AWS
  • Linux
No Result
View All Result
PikoPong
No Result
View All Result
Home Web Dev

Laravel Package for Server-Side GA Event Tracking

May 24, 2020
in Web Dev
272 20
Laravel Package for Server-Side GA Event Tracking


Analytics Event Tracking is a Laravel package by pascalbaljet to send Laravel events to Google Analytics from the server-side easily. This package works by fetching the GA client ID on the client-side (via a blade directive) and sending it to the backend for storage in the user’s session, so later events have access to the client ID when sending info to GA.

It integrates with Laravel’s event system, and you only need to implement the ShouldBroadcastToAnalytics interface to send your events to GA.

Here’s an example from the package author’s writeup about the package:

namespace AppEvents;

use AppOrder;
use TheIconicTrackingGoogleAnalyticsAnalytics;
use IlluminateFoundationEventsDispatchable;
use IlluminateQueueSerializesModels;
use ProtoneMediaAnalyticsEventTrackingShouldBroadcastToAnalytics;

class OrderWasPaid implements ShouldBroadcastToAnalytics
{
    use Dispatchable, SerializesModels;

    public $order;

    public function __construct(Order $order)
    {
        $this->order = $order;
    }

    // optional
    public function withAnalytics(Analytics $analytics)
    {
        $analytics->setEventValue($this->order->sum_in_cents / 100);
    }

    // optional
    public function broadcastAnalyticsActionAs(Analytics $analytics)
    {
        return 'CustomEventAction';
    }
}

The package’s main features include:

Learn More

Check out the author’s post Tracking events with Google Analytics and a new Laravel package for more details about the creation of this package.

You can learn more about this package, get full installation instructions, and view the source code on GitHub at pascalbaljetmedia/laravel-analytics-event-tracking.

Filed in:
News



Source link

Share219Tweet137Share55Pin49

Related Posts

2020 Roundup of Web Research
Web Dev

CSS-Tricks Chronicle XXXIX | CSS-Tricks

I’ve been lucky enough to be a guest on some podcasts and at some events, so I thought I’d...

March 6, 2021
A Super Flexible CSS Carousel, Enhanced With JavaScript Navigation
Web Dev

A Super Flexible CSS Carousel, Enhanced With JavaScript Navigation

Not sure about you, but I often wonder how to build a carousel component in such a way that...

March 5, 2021
Language in Dev Culture | Laravel News
Web Dev

Language in Dev Culture | Laravel News

How we use language in development-centric circles is as important as the code we design and the sprints (development...

March 5, 2021
Through the pipeline: An exploration of front-end bundlers
Web Dev

Through the pipeline: An exploration of front-end bundlers

This last week I spent a lot of time buried deep in the documentation of parcel, rollup, and esbuild....

March 5, 2021
Next Post
How To Create A Mobile App In Expo And Firebase (For iOS And Android) — Smashing Magazine

How To Create A Mobile App In Expo And Firebase (For iOS And Android) — Smashing Magazine

Responsive Web Design Basics

Responsive Web Design Basics

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Recommended

An Open Standard For JavaScript Functions — Smashing Magazine

An Open Standard For JavaScript Functions — Smashing Magazine

May 24, 2020
Enable fine-grained permissions for Amazon QuickSight authors in AWS Lake Formation : idk.dev

Enable fine-grained permissions for Amazon QuickSight authors in AWS Lake Formation : idk.dev

June 30, 2020

Dreaming Of A Magical December (2020 Wallpapers Edition) — Smashing Magazine

November 30, 2020
Block Links: The Search for a Perfect Solution

Block Links: The Search for a Perfect Solution

May 25, 2020

Categories

  • AWS
  • Big Data
  • Database
  • DevOps
  • IoT
  • Linux
  • Web Dev
No Result
View All Result
  • Web Dev
  • Hack
  • Database
  • Big Data
  • AWS
  • Linux

Welcome Back!

Login to your account below

Forgotten Password?

Create New Account!

Fill the forms bellow to register

All fields are required. Log In

Retrieve your password

Please enter your username or email address to reset your password.

Log In