prajwal89/lara-click-insights
最新稳定版本:v0.1.4
Composer 安装命令:
composer require prajwal89/lara-click-insights
包简介
Track impressions and clicks
README 文档
README
Record impressions and clicks of any model with Lara Click Insights
Installation
- Install the package via composer:
composer require prajwal89/lara-click-insights
- Publish frontend assets:
php artisan vendor:publish --tag=lara-click-insights-assets
- Publish Database migrations:
php artisan vendor:publish --tag=lara-click-insights-migrations
- Publish Database config (optional):
php artisan vendor:publish --tag=lara-click-insights-config
Alternatively, you can publish all of the above with the following command:
php artisan vendor:publish
When prompted, select Prajwal89\LaraClickInsights\LaraClickInsightsProvider.
In your HTML <head> tag, add the following directive and meta tag:
<html> <head> <meta name="csrf-token" content="{{ csrf_token() }}"> ... @LaraClickInsightsJs </head>
Do not forget to run php artisan migrate
Usage
The Eloquent models you want to track impressions for should use the Prajwal89\LaraClickInsights\Traits\ImpressionTrackable trait.
namespace App; use Prajwal89\LaraClickInsights\Traits\ImpressionTrackable; use Illuminate\Database\Eloquent\Model; class YourEloquentModel extends Model { use ImpressionTrackable; ... }
The trait contains an abstract method trackingAttribute() that you must implement yourself on your frontend. this should look something like this
<!-- cards that you want to track --> @foreach($yourEloquentModels as $yourEloquentModel) <a href="/xyz" {!! $yourEloquentModel->trackingAttribute() !!}> <!-- card content --> </a> @foreach
this will add data attribute for identifying the clickable link like data-clickable="yourEloquentModels:23:default"
do not forget to use {!! !!}
License
The MIT License (MIT). Please see License File for more information.
统计信息
- 总下载量: 137
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 3
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: Unknown
- 更新时间: 2024-05-06