• Stars
    star
    321
  • Rank 130,752 (Top 3 %)
  • Language
    PHP
  • License
    MIT License
  • Created over 9 years ago
  • Updated almost 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

πŸ“Š Laravel Google Analytics Measurement Protocol Package

Laravel-GAMP Package

Join PHP Chat Chat on Telegram Laravel & Lumen Package Latest Version on Packagist Software License Total Downloads

Laravel GAMP: Google Analytics Measurement Protocol Package for Laravel & Lumen.

Send data to Google Analytics from Laravel/Lumen. Supports all GA Measurement Protocol API methods.

Laravel GAMP

Quick start

Install

Step 1: Install Through Composer

$ composer require irazasyed/laravel-gamp

(Lumen) Add the Service Provider

Open bootstrap/app.php and register the service provider by adding:

$app->register(Irazasyed\LaravelGAMP\LaravelGAMPServiceProvider::class);

Step 2: Publish Config

Open your terminal window and fire the following command to publish config file to your config directory:

$ php artisan vendor:publish --provider="Irazasyed\LaravelGAMP\LaravelGAMPServiceProvider"

Usage

Open config file config/gamp.php and set the tracking_id with your Google Analytics tracking / web property ID. Refer the config file for other default configuration settings.

This Package adds Laravel Support to GA Measurement Protocol PHP Library by THE ICONIC. It's simply a wrapper around the library with default config for easier usage with Laravel. So all the methods listed here are available and will work seamlessly.

Example Usage

Send a Page view hit:

use Irazasyed\LaravelGAMP\Facades\GAMP;

$gamp = GAMP::setClientId( '123456' );
$gamp->setDocumentPath( '/page' );
$gamp->sendPageview();

Send an Event:

use Irazasyed\LaravelGAMP\Facades\GAMP;

$gamp = GAMP::setClientId( '123456' );
$gamp->setEventCategory('Blog Post')
->setEventAction('Create')
->setEventLabel('Using GAMP In Laravel')
->sendEvent();

Config Overview

Open the config file for detailed comments for each option.

Set your Google Analytics Tracking / Web Property ID in tracking_id key [REQUIRED]

'tracking_id' => 'UA-XXXX-Y',

All other configuration options are optional, use as per your requirements.

To send data over SSL, set is_ssl to true.

'is_ssl' => true,

To disable library in Staging/Dev env (Prevents the library from sending any hits to GA), set is_disabled to true.

'is_disabled' => true,

To Anonymize IP, set anonymize_ip to true.

'anonymize_ip' => true,

To Make Async Requests, set async_requests to true.

'async_requests'  => true,

...

Refer the library's documentation for other remaining methods and examples, they all work.

Note: You don't have to use the protocol version, tracking id, anonymize ip and async request (non-blocking) methods from the original library as they're automatically set in Service Provider when the package is initialized based on the config file. As long as you update the config file with correct settings, it should work just fine.

Additional information

Any issues, please report here

Credits

License

The MIT License (MIT). Please see License File for more information.

FOSSA Status

More Repositories

1

telegram-bot-sdk

πŸ€– Telegram Bot API PHP SDK. Lets you build Telegram Bots easily! Supports Laravel out of the box.
PHP
2,909
star
2

awesome-cloudflare

⛅️ Curated list of awesome Cloudflare worker recipes, open-source projects, guides, blogs and other resources.
416
star
3

jwt-auth-guard

JWT Auth Guard for Laravel and Lumen Frameworks.
PHP
323
star
4

larasupport

πŸ“¦ Adds Laravel Packages Support to Lumen and Vendor Publish Artisan Command.
PHP
126
star
5

video-downloader

Video Downloader for Facebook.
PHP
69
star
6

dns-zone-files

⛅️ DNS Zone Files ready to import on CloudFlare for easy configurations of common configs. Files are in BIND Format.
46
star
7

awesome-laravel-forge-recipes

πŸ₯£ Awesome Laravel Forge Recipes
Shell
45
star
8

laravel-identicon

πŸ‘€ Laravel Identicon Package
PHP
22
star
9

zray-installer

Zend Z-Ray Easy Installer for Laravel Homestead
Shell
22
star
10

php-transmission-sdk

πŸ”„ PHP Transmission-RPC API SDK with Laravel Support.
PHP
20
star
11

phpci-installer

PHPCI Easy Installer for Laravel Homestead
Shell
19
star
12

docgen

πŸ“– Streamline your Laravel package development with automatic facade documentation using Docgen for Laravel.
PHP
18
star
13

php-witai

[WIP] PHP Library for Wit.Ai API with Laravel & Lumen Support out of the box!
PHP
11
star
14

xml-rpc-ping

PHP XML-RPC Service Pinger
PHP
11
star
15

gsuite-checker

Google Suite (GSuite) formerly known as Google Apps - Multi-Domains Checker.
PHP
9
star
16

nginx-google-ip-range-updater

Google PageSpeed IP Ranges Updater for Nginx
Shell
7
star
17

wp-drp-coupon

Mirror of WordPress Plugin - DRP Coupon
PHP
5
star
18

laravel-facebook

Laravel 4 Facebook SDK Package (Deprecated - Use the official Lib, latest version).
PHP
5
star
19

php-ip-range

Checks if IP is within a network range
PHP
5
star
20

gitlab-installer

Server setup for Gitlab Installation on Ubuntu/Linux VPS with helper bash scripts.
Shell
4
star
21

fb-kit

Facebook Graph API JS Kit - To work with Graph API using access token.
JavaScript
3
star
22

awesome-deno

Awesome Deno Land List
1
star
23

php-ixr

This is a fork of the original Incutio PHP XML-RPC library (IXR) SVN repo hosted on Google Code http://scripts.incutio.com/xmlrpc/
1
star
24

phpstorm-settings

1
star
25

jquery-form-helper

jQuery Form Helper - Forked from JREAM BitBucket - http://bitbucket.org/JREAM/js-util
JavaScript
1
star
26

ST3-Preferences

My Sublime Text 3 Preferences
1
star
27

irazasyed

1
star
28

php-chrome-driver-installer

PHP Chrome Driver Installer
PHP
1
star
29

php-stock-media

🏞️ PHP Stock Media - the ultimate library for sourcing stock images, stock videos, and other stock media resources from multiple online stock services with Laravel support out of the box!
PHP
1
star