Package Data | |
---|---|
Maintainer Username: | HighSolutions |
Maintainer Contact: | adam@highsolutions.pl (HighSolutions) |
Package Create Date: | 2017-07-31 |
Package Last Update: | 2020-09-09 |
Language: | PHP |
License: | MIT |
Last Refreshed: | 2024-11-08 03:08:43 |
Package Statistics | |
---|---|
Total Downloads: | 170 |
Monthly Downloads: | 0 |
Daily Downloads: | 0 |
Total Stars: | 10 |
Total Watchers: | 1 |
Total Forks: | 4 |
Total Open Issues: | 0 |
A Laravel package for synchronizing with Google Search Console to get visitors' search keywords.
Add the following line to the require
section of your Laravel webapp's composer.json
file:
"require": {
"HighSolutions/GoogleKeywords": "1.*"
}
Run composer update
to install the package.
This package uses Laravel 5.5 Package Auto-Discovery.
For previous versions of Laravel, you need to update config/app.php
by adding an entry for the service provider:
'providers' => [
// ...
HighSolutions\GoogleKeywords\GoogleKeywordsServiceProvider::class,
];
Next, publish all package resources:
php artisan vendor:publish --provider="HighSolutions\GoogleKeywords\GoogleKeywordsServiceProvider"
This will add to your project:
- migration - database table for storing keywords
- configuration - package configurations
Remember to launch migration:
php artisan migrate
Next step is to add cron task via Scheduler (app\Console\Kernel.php
):
protected function schedule(Schedule $schedule)
{
// ...
$schedule->command('keywords:fetch')->daily();
}
| Setting name | Description | Default value | |------------------------|-----------------------------------|----------------------------------------------------| | websites..url | URL of website (with protocol) | '' | | websites..credentials | JSON credentials file on server | storage_path('app/google-search-credentials.json') |
Websites are defined in configuration as:
<?php
return [
'websites' => [
[
'url' => 'http://highsolutions.pl',
'credentials' => storage_path('app/HS-Credentials.json'),
],
// ...
],
];
Invalid configuration will return information about error.
In order to get access to keywords from Google Search you need to complete 2 steps:
storage/app
folderModel consists of fields:
id
- primary keyurl
- URL of websitekeyword
- full keyworddate
- date of resultclicks
- number of clicks on link in search view with particular keywordimpressions
- number of views of link in search view with particular keywordctr
- click through rate (clicks / impressions)avg_position
- average position of link on list of results in search view with particular keywordTo make usage of gathered data easier, there is a simple API for most common use cases:
url('http://example.com')
- adds where clause for limiting results to only one website (not necessary when you fetch only one website)grouped()
- prepares sum of clicks and impressions of each keyword gathered for the websitebyDay()
- prepares sum of clicks and impressions of each dayorderByDate($dir = 'asc')
- sorts results by dateorderBySum($param = 'clicks')
- sorts results by sum of clicks/impressions (works with grouped
scope)orderByAlpha($dir = 'asc')
- sorts results alphabetically<?php
use HighSolutions\GoogleKeywords\Models\GoogleKeyword;
$results = GoogleKeyword::url('http://highsolutions.pl')->grouped()->orderBySum('clicks')->take(10)->get();
<?php
use HighSolutions\GoogleKeywords\Models\GoogleKeyword;
$results = GoogleKeyword::url('http://highsolutions.pl')->orderByDate()->get();
<?php
use Carbon\Carbon;
use HighSolutions\GoogleKeywords\Models\GoogleKeyword;
$results = GoogleKeyword::url('http://highsolutions.pl')->byDate()->where('date', '>=', Carbon::now()->subMonth(1))->orderByDate()->get();
1.0.3
1.0.2
1.0.0
This package is developed by HighSolutions, software house from Poland in love in Laravel.