Skip to content
This repository was archived by the owner on Jan 2, 2024. It is now read-only.

Commit 3472520

Browse files
committed
Update README.md
1 parent 3a3863a commit 3472520

File tree

1 file changed

+24
-3
lines changed

1 file changed

+24
-3
lines changed

README.md

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,14 @@ https://twitter.com/pascalbaljet/status/1257926601339277312
66
[![Quality Score](https://img.shields.io/scrutinizer/g/pascalbaljetmedia/laravel-analytics-event-tracking.svg?style=flat-square)](https://scrutinizer-ci.com/g/pascalbaljetmedia/laravel-analytics-event-tracking)
77
[![Total Downloads](https://img.shields.io/packagist/dt/protonemedia/laravel-analytics-event-tracking.svg?style=flat-square)](https://packagist.org/packages/protonemedia/laravel-analytics-event-tracking)
88

9-
Laravel package to easily send events to Google Analytics
9+
Laravel package to easily send events to [Google Analytics](https://analytics.google.com/)
1010

1111
## Features
12-
* Use [Laravel Events](https://laravel.com/docs/7.x/events) to track events with Google Analytics
13-
* All API calls are queued.
12+
* Use [Laravel Events](https://laravel.com/docs/7.x/events) to track events with GA.
13+
* [Blade Directive](https://laravel.com/docs/7.x/blade#introduction) to easily store the Client ID.
14+
* Full access to the [underlying library](https://github.com/theiconic/php-ga-measurement-protocol).
15+
* API calls to GA are queued.
16+
* Easy to configure.
1417
* Compatible with Laravel 6.0 and 7.0.
1518
* PHP 7.4 required.
1619

@@ -36,6 +39,24 @@ Set your [Google Analytics Tracking ID](https://support.google.com/analytics/ans
3639
GOOGLE_ANALYTICS_TRACKING_ID=UA-01234567-89
3740
```
3841

42+
## Blade Directive
43+
44+
This package comes with a `@sendAnalyticsClientId` directive that stores the `Client ID` from the GA front-end to your Laravel backend. It uses the [Axios HTTP library](https://github.com/axios/axios) the make an asynchronous POST request. Axios was choosen as it is provided by default in the `resources/js/bootstrap.js` file.
45+
46+
```php
47+
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-01234567-89"></script>
48+
<script>
49+
window.dataLayer = window.dataLayer || [];
50+
function gtag(){dataLayer.push(arguments);}
51+
gtag('js', new Date());
52+
gtag('config', 'UA-01234567-89', { 'anonymize_ip': true, 'forceSSL': true });
53+
54+
@sendAnalyticsClientId
55+
</script>
56+
```
57+
58+
If you don't use Axios, you have to implement this call by yourself.
59+
3960
## Broadcast Events to Google Analytics
4061

4162
Add the `ShouldBroadcastToAnalytics` interface to your event and you're ready! You don't have to manually bind any listeners.

0 commit comments

Comments
 (0)