PHP code example of akki-io / laravel-google-analytics
1. Go to this page and download the library: Download akki-io/laravel-google-analytics library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
akki-io / laravel-google-analytics example snippets
use AkkiIo\LaravelGoogleAnalytics\Facades\LaravelGoogleAnalytics;
use AkkiIo\LaravelGoogleAnalytics\Period;
use Google\Analytics\Data\V1beta\Filter\StringFilter\MatchType;
use Google\Analytics\Data\V1beta\MetricAggregation;
use Google\Analytics\Data\V1beta\Filter\NumericFilter\Operation;
// get the top 20 most viewed pages for last 30 days
LaravelGoogleAnalytics::getMostViewsByPage(Period::days(30), $count = 20);
// get the top 20 dates with most users for last 12 months
LaravelGoogleAnalytics::getMostUsersByDate(Period::months(12), $count = 20);
// build a query using the `get()` method
LaravelGoogleAnalytics::dateRanges(Period::days(30), Period::days(60))
->metrics('active1DayUsers', 'active7DayUsers')
->dimensions('browser', 'language')
->metricAggregations(MetricAggregation::TOTAL, MetricAggregation::MINIMUM)
->whereDimension('browser', MatchType::CONTAINS, 'firefox')
->whereMetric('active7DayUsers', Operation::GREATER_THAN, 50)
->orderByDimensionDesc('language')
->get();
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.