stelianandrei/laravel-server-side-ga 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

stelianandrei/laravel-server-side-ga

Composer 安装命令:

composer require stelianandrei/laravel-server-side-ga

包简介

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

README 文档

README

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

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.

Installation

First thing you need to do is require the package using composer.

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:

  StelianAndrei\LaravelServerSideGA\AnalyticsServiceProvider::class,

Also add the Analytics facade to the aliases array in the same file:

  '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:

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.

Tracking page views

To track page views, use it as follows:

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

Where:

  • $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:

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

Where:

  • $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

统计信息

  • 总下载量: 1.34k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2018-06-12

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固