necessarylion/php-analytics
Composer 安装命令:
composer require necessarylion/php-analytics
包简介
Google analytics alternative of laravel-analytics
README 文档
README
composer require necessarylion/php-analytics
<?php
use Carbon\Carbon;
use Necessarylion\Analytics;
require __DIR__."/vendor/autoload.php";
$analytics = new Analytics;
$analytics->setViewId('XXXXXXXXX');
$analytics->setCredentialPath(__DIR__ . "/analytics.json");
$analytics->init();
- setup start date and end date
$analytics->setStartDate(Carbon::now());
$analytics->setEndDate(Carbon::now());
-
get top referrers links
$analytics->getTopReferrers(); -
get total visitors and total page view
$analytics->getTotalVisitorAndPageView(); -
get visitor type with total views eg. New Visitor, Returning Visitor
$analytics->getUserTypes(); -
get top 20 most visited pages
$analytics->getMostVisitedPages(); -
run custom query
$analytics->runQuery('ga:users,ga:sessions,ga:bounceRate,ga:avgSessionDuration');
$result = $analytics->getResult(['users', 'sessions', 'bounceRate', 'sessionDuration']);
print_r($result);
- get raw response
$result = $analytics->getResponse();
统计信息
- 总下载量: 30
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2021-04-21