API Documentation
The pages provides documentation on all methods provided by this package.
- Introduction
- Stat Methods
- Tracker Method
- Summary Method
- Recent Visitors Method
- Popular Pages Method
- Entry Pages Method
- Exit Pages Method
- Came From Method
- Recent Keywords Method
- Browsers Method
- Operating Systems Method
- Search Engines Method
- Country Method
- Recent Pageload Method
- Exit Link Method
- Download Link Method
- Visit Length Method
- Returning Visits Method
- Keyword Analysis Method
- Lookup Visitor Method
- Stat Utility Methods
- Set Range Method
- Project Method
- Set Username Method
- Set Password Method
- Number Of Results Method
- Project Administration Methods
- Add Project Method
- Update Project Method
- Update Logsize Method
- Account Logsizes Method
- Account Projects Method
- Select Project Method
- Laravel DB Style Methods
- Offset Method
- Skip Method
- Limit Method
- Take Method
- For Page Method
- Chunk Method
- To URL Method
- Remember Method
- Remember Forever Method
- Cache Tags Method
- Cache Driver Method
- Pluck Method
- First Method
- Get Method
- Get Fresh Method
- Get Cached Method
- Get Cache Key Method
- Generate Cache Key Method
- Paginate Method
- Get Pagination Count Method
- Simple Paginate Method
- Exists Method
- Count Method
- New Query Method
- Raw Method
- Columns Method
- Get Columns Method
•Introduction
As previously mentioned, this package was designed based on the Laravel DB Query class. This choice was made due to the fact that the StatCounter API is simply exposing access to their databases.
When utilizing this package to make queries, you will be returned the data array given by the StatCounter API. For more specific information on what is returned for each query, please read the StatCounter API Documentation.
Also note, API errors will throw a StatException
with the their error message.
•Tracker Method
Displays the StatCounter tracker for the project.
echo Stat::tracker();
-
isHttps
[boolean][optional] - Whether or not to use the https scheme. Default is false. -
isVisible
[boolean][optional] - Whether or not to use a visible tracker. Default is false. -
websiteTitle
[string][optional] - Only necessary if specifying projects other than the default given in the config. Must match one of the project alias names.
String - The standard tracker code as shown below.
<script type="text/javascript">
var sc_project=0123456;
var sc_invisible=0;
var sc_security="abcd0123";
var sc_https=0;
var scJsHost = (("https:" == document.location.protocol) ?
"https://secure." : "http://www.");
document.write("<sc"+"ript type=\'text/javascript\' src=\'" +
scJsHost+
"statcounter.com/counter/counter.js\'></"+"script>");
</script>
<noscript><div class="statcounter"><a title="hits counter"
href="http://statcounter.com/" target="_blank"><img
class="statcounter"
src="http://c.statcounter.com/0123456/0/abcd0123/0/"
alt="hits counter"></a></div></noscript>
•Summary Method
Starts a 'summary' query. See http://api.statcounter.com/docs/v3#summary.
Note: This doesn't actually submit the query. You must use the Get Method to submit stat type queries.
$stats = Stat::summary()->get();
None
$this
•Recent Visitors Method
Starts a 'recent visitor' query. See http://api.statcounter.com/docs/v3#visitors.
Note: This doesn't actually submit the query. You must use the Get Method to submit stat type queries.
$stats = Stat::recentVisitors()->get();
None
$this
•Popular Pages Method
Starts a 'popular pages' query. See http://api.statcounter.com/docs/v3#popular.
Note: This doesn't actually submit the query. You must use the Get Method to submit stat type queries.
$stats = Stat::popularPages()->get();
-
chopUrl
[boolean][optional] - Chop the query string from the returned URL. Many URLs contain data variables in a query string that is used to set details on the web page. Chopping the query string can make the returned URL list easier to read and less cluttered. Default is true. -
countType
[boolean][optional] - The type of counts used by a stat. Default value isCOUNT_TYPE_PAGE_VIEW
. The available options are:-
COUNT_TYPE_PAGE_VIEW
[const] - Stats are counted by page views -
COUNT_TYPE_VISITOR
[const] - Stats are counted by visitors
-
$this
•Entry Pages Method
Starts a 'entry pages' query. See http://api.statcounter.com/docs/v3#entry.
Note: This doesn't actually submit the query. You must use the Get Method to submit stat type queries.
$stats = Stat::entryPages()->get();
None
$this
•Exit Pages Method
Starts a 'exit pages' query. See http://api.statcounter.com/docs/v3#exit.
Note: This doesn't actually submit the query. You must use the Get Method to submit stat type queries.
$stats = Stat::exitPages()->get();
None
$this
•Came From Method
Starts a 'came from' query. See http://api.statcounter.com/docs/v3#camefrom.
Note: This doesn't actually submit the query. You must use the Get Method to submit stat type queries.
$stats = Stat::cameFrom()->get();
-
external
[boolean][optional] - Choose to exclude external results to your site. Default is true. -
excludeSearchEngines
[boolean][optional] - Choose to exclude search engine driven results to your site. Default is false. -
groupByDomain
[boolean][optional] - Choose to group results by referring domain. Default is false.
$this
•Recent Keywords Method
Starts a 'recent keywords' query. See http://api.statcounter.com/docs/v3#keyword-activity.
Note: This doesn't actually submit the query. You must use the Get Method to submit stat type queries.
$stats = Stat::recentKeywords()->get();
-
excludeEncryptedKeywords
[boolean][optional] - Choose to exclude encrypted keyword results. Default is false. -
external
[boolean][optional] - Choose to exclude external results to your site. Default is true.
$this
•Browsers Method
Starts a 'browsers' query. See http://api.statcounter.com/docs/v3#browsers.
Note: This doesn't actually submit the query. You must use the Get Method to submit stat type queries.
$stats = Stat::browsers()->get();
-
device
[integer][optional] - Choose the device type. Default value isDEVICE_All
. The available options are:-
DEVICE_All
[const] - All devices -
DEVICE_DESKTOP
[const] - Only desktop devices -
DEVICE_MOBILE
[const] - Only mobile devices
-
$this
•Operating Systems Method
Starts a 'operating systems' query. See http://api.statcounter.com/docs/v3#os.
Note: This doesn't actually submit the query. You must use the Get Method to submit stat type queries.
$stats = Stat::operatingSystems()->get();
-
device
[integer][optional] - Choose the device type. Default value isDEVICE_All
. The available options are:-
DEVICE_All
[const] - All devices -
DEVICE_DESKTOP
[const] - Only desktop devices -
DEVICE_MOBILE
[const] - Only mobile devices
-
$this
•Search Engines Method
Starts a 'search engines' query. See http://api.statcounter.com/docs/v3#search_engine.
Note: This doesn't actually submit the query. You must use the Get Method to submit stat type queries.
$stats = Stat::searchEngines()->get();
None
$this
•Country Method
Starts a 'country' query. See http://api.statcounter.com/docs/v3#country.
Note: This doesn't actually submit the query. You must use the Get Method to submit stat type queries.
$stats = Stat::country()->get();
None
$this
•Recent Pageload Method
Starts a 'recent pageload' query. See http://api.statcounter.com/docs/v3#pageload.
Note: This doesn't actually submit the query. You must use the Get Method to submit stat type queries.
$stats = Stat::recentPageload()->get();
-
device
[integer][optional] - Choose the device type. Default value isDEVICE_All
. The available options are:-
DEVICE_All
[const] - All devices -
DEVICE_DESKTOP
[const] - Only desktop devices -
DEVICE_MOBILE
[const] - Only mobile devices
-
$this
•Exit Link Method
Starts a 'exit link' query. See http://api.statcounter.com/docs/v3#exit-link-activity.
Note: This doesn't actually submit the query. You must use the Get Method to submit stat type queries.
$stats = Stat::exitLink()->get();
-
device
[integer][optional] - Choose the device type. Default value isDEVICE_All
. The available options are:-
DEVICE_All
[const] - All devices -
DEVICE_DESKTOP
[const] - Only desktop devices -
DEVICE_MOBILE
[const] - Only mobile devices
-
$this
•Download Link Method
Starts a 'download link' query. See http://api.statcounter.com/docs/v3#download-link-activity.
Note: This doesn't actually submit the query. You must use the Get Method to submit stat type queries.
$stats = Stat::downloadLink()->get();
-
device
[integer][optional] - Choose the device type. Default value isDEVICE_All
. The available options are:-
DEVICE_All
[const] - All devices -
DEVICE_DESKTOP
[const] - Only desktop devices -
DEVICE_MOBILE
[const] - Only mobile devices
-
$this
•Visit Length Method
Starts a 'visit length' query. See http://api.statcounter.com/docs/v3#visit-length.
Note: This doesn't actually submit the query. You must use the Get Method to submit stat type queries.
$stats = Stat::visitLength()->get();
None
$this
•Returning Visits Method
Starts a 'returning visits' query. See http://api.statcounter.com/docs/v3#returning-visits.
Note: This doesn't actually submit the query. You must use the Get Method to submit stat type queries.
$stats = Stat::returningVisits()->get();
None
$this
•Keyword Analysis Method
Starts a 'keyword analysis' query. See http://api.statcounter.com/docs/v3#keyword-analysis.
Note: This doesn't actually submit the query. You must use the Get Method to submit stat type queries.
$stats = Stat::keywordAnalysis()->get();
-
combineKeywords* [integer][optional] - Choose to combine keyword results based on one of three possible criteria. Default value is
SEARCH_ENGINE_HOST`. The available options are:-
SEARCH_ENGINE_HOST
[const] - Groups results by common search engine host values -
SEARCH_ENGINE_NAME
[const] - Groups results by common search engine names -
SEARCH_ENGINE_TOGETHER
[const] - Groups results by common keyword values
-
-
excludeEncryptedKeywords
[boolean][optional] - Choose to exclude encrypted keyword results. Default is false.
$this
•Lookup Visitor Method
Starts a 'lookup visitor' query. See http://api.statcounter.com/docs/v3#lookup-visitor.
Note: This doesn't actually submit the query. You must use the Get Method to submit stat type queries.
$stats = Stat::lookupVisitor('127.0.0.1')->get();
-
ipAddress
[string] - The I.P. address of a visitor you want to look up.
$this
•Set Range Method
Optional method. Sets the range of the selected Stat Query. See http://api.statcounter.com/docs/v3#date-range.
$stats = Stat::popularPages()->setRange(\Injic\LaravelStatcounter\Stat::GRAN_WEEKLY, new Carbon('first day of January 2008', 'America/Vancouver'), new Carbon())->get();
-
granularity
[string] - The time interval of returned stats. Default value isGRAN_WEEKLY
. The available options are:-
GRAN_HOURLY
[const] - Hourly interval granularity in results -
GRAN_DAILY
[const] - Daily interval granularity in results -
GRAN_WEEKLY
[const] - Weelly interval granularity in results -
GRAN_MONTHLY
[const] - Monthly interval granularity in results -
GRAN_QUARTERLY
[const] - Quarterly interval granularity in results -
GRAN_YEARLY
[const] - Yearly interval granularity in results
-
-
start
[integer|string|Carbon] - The starting date for the range. Accepts an integer timestamps, a string with PHP Supported Date and Time Formats, a DateTimeZone instance, or a Carbon instance. The default is the first day of the year. -
end
[integer|string|Carbon] - The ending date for the range. Accepts same asstart
. The default is the last day of the year.
$this
•Project Method
Optional method. Sets the project(s) of the selected Query. See http://api.statcounter.com/docs/v3#batch.
$stats = Stat::project('Example Website')->lookupVisitor('127.0.0.1')->get();
-
websiteTitle
[string] - The name of the project alias in the config e.g. 'My Website'.
$this
•Set Username Method
Optional method. Sets the username of the selected Query.
$stats = Stat::project('Example Website')->setUsername('SOme UsEr')->get();
-
username
[string] - Your StatCounter username.
$this
•Set Password Method
Optional method. Sets the password of the selected Query.
$stats = Stat::project('Example Website')->setUsername('SOme UsEr')->setPassword('some_Passw0rd')->get();
-
password
[string] - Your StatCounter API password.
$this
•Number Of Results Method
Optional method. Sets the number of results to be returned with the query. The default is 1000.
Note: StatCounter's default is 20, it is overridden by default with 1000. Some queries will provide all results when -1 is passed, while others return a MySQL error.
$stats = Stat::recentVisitors()->numberOfResults(10)->get();
-
num
[integer] - The number of results to be returned with the query.
$this
•Add Project Method
Starts a 'add project' query. See http://api.statcounter.com/docs/v3#create-project.
$project = Stat::addProject('Example Website','example.com','America/Chicago');
-
websiteTitle
[string] - The name that will be given to the new StatCounter project e.g. 'My Website'. -
websiteUrl
[string] - The URL of the website e.g. 'http://www.mywebsite.com/'. -
timezone
[string] - The time zone to be used for the project stats e.g.'America/New_York'
. See Time Zone Options for the complete list. The default is'America/New_York'
. -
publicStats
[integer][optional] - Set the level of public access to stats in a project. Default value isPUBLIC_STATS_NONE
. The available options are:-
PUBLIC_STATS_NONE
[const] - All stats are private -
PUBLIC_STATS_ALL
[const] - All stats are public -
PUBLIC_STATS_SUMMARY
[const] - Only summary stats are public
-
Array
•Update Project Method
Starts a 'update project' query. See http://api.statcounter.com/docs/v3#update-project.
$project = Stat::updateProject('Example Website',\Injic\LaravelStatcounter\Stat::PUBLIC_STATS_NONE);
-
websiteTitle
[string][optional] - The name of the project alias in the config e.g. 'My Website'. Default value is config-defined default project. -
publicStats
[integer][optional] - Set the level of public access to stats in a project. Default value isPUBLIC_STATS_NONE
. The available options are:-
PUBLIC_STATS_NONE
[const] - All stats are private -
PUBLIC_STATS_ALL
[const] - All stats are public -
PUBLIC_STATS_SUMMARY
[const] - Only summary stats are public
-
Array
•Update Logsize Method
Starts a 'update logsize' query. See http://api.statcounter.com/docs/v3#increase-logsize.
$project = Stat::updateLogsize('Example Website');
-
websiteTitle
[string][optional] - The name of the project alias in the config e.g. 'My Website'. Default value is config-defined default project.
Array
•Account Logsizes Method
Starts a 'account logsizes' query. See http://api.statcounter.com/docs/v3#retrieve-logsizes.
$project = Stat::userDetails();
None
Array
•User Details Method
Starts a 'user details' query. See http://api.statcounter.com/docs/v3#user-details.
$project = Stat::userDetails();
-
username
[string][optional] - Your StatCounter username. Default value is config-defined username. -
password
[string][optional] - Your StatCounter API password. Default value is config-defined API password.
Array
•User Projects Method
Starts a 'user projects' query. See http://api.statcounter.com/docs/v3#user-projects.
$project = Stat::userProjects();
-
username
[string][optional] - Your StatCounter username. Default value is config-defined username. -
password
[string][optional] - Your StatCounter API password. Default value is config-defined API password.
Array
•Select Project Method
Starts a 'select project' query. See http://api.statcounter.com/docs/v3#select-project.
$project = Stat::selectProject();
-
websiteTitle
[string][optional] - The name of the project alias in the config e.g. 'My Website'. Default value is config-defined default project.
Array
•Offset Method
Set the "offset" value of the query.
$stats = Stat::recentVisitors()->offset(5)->get();
-
value
[integer]
$this
•Skip Method
Alias to set the "offset" value of the query.
$stats = Stat::recentVisitors()->skip(5)->get();
-
value
[integer]
$this
•Limit Method
Set the "limit" value of the query. Different from the Number Of Results Method because it handles the results after receiving them in order to paginate.
Note: StatCounter would need to expose offsetting in their API in order to handle pagination on the database side.
$stats = Stat::recentVisitors()->limit(10)->get();
-
value
[integer]
$this
•Take Method
Alias to set the "limit" value of the query.
$stats = Stat::recentVisitors()->take(5)->get();
-
value
[integer]
$this
•For Page Method
Set the limit and offset for a given page.
$stats = Stat::recentVisitors()->forPage(2)->get();
-
page
[integer] -
perPage
[integer]
$this
•Chunk Method
Chunk the results of the query.
$stats = Stat::recentVisitors()->chunk(15, function(){
...
});
-
count
[integer] -
callback
[callable]
void
•To URL Method
Compiles a StatCounter API query URL based on the given query paramters.
$url = Stat::recentVisitors()->skip(5)->toUrl();
None
$this
•Remember Method
Indicate that the query results should be cached.
$stats = Stat::recentVisitors()->skip(5)->remember(15)->get();
-
minutes
[integer]
$this
•Remember Forever Method
Indicate that the query results should be cached forever.
$stats = Stat::recentVisitors()->skip(5)->rememberForever()->get();
None
$this
•Cache Tags Method
Indicate that the results, if cached, should use the given cache tags.
$stats = Stat::recentVisitors()->take(5)->cacheTags('stats')->remember(15)->get();
-
cacheTags
[array|dynamic]
$this
•Cache Driver Method
Indicate that the results, if cached, should use the given cache driver.
$stats = Stat::recentVisitors()->take(5)->cacheDriver('redis')->remember(15)->get();
-
cacheTags
[string]
$this
•Pluck Method
Pluck a single column's value from the first result of a query.
$stats = Stat::recentVisitors()->pluck('os');
-
column
[string]
mixed
•First Method
Execute the query and get the first result.
$stats = Stat::recentVisitors()->first();
-
columns
[array]
mixed
•Get Method
Execute the query and get the result(s).
$stats = Stat::recentVisitors()->get();
-
columns
[array]
mixed
•Get Fresh Method
Execute the query as a fresh call to the API.
$stats = Stat::recentVisitors()->getFresh();
-
columns
[array]
mixed
•Get Cached Method
Execute the query as a cached call to the API.
$stats = Stat::recentVisitors()->getCached();
-
columns
[array]
mixed
•Get Cache Key Method
Get a unique cache key for the complete query.
$stats = Stat::recentVisitors()->getCacheKey();
None
string
•Generate Cache Key Method
Generate the unique cache key for the query.
$stats = Stat::recentVisitors()->generateCacheKey();
None
string
•Generate Cache Key Method
Generate the unique cache key for the query.
$stats = Stat::recentVisitors()->generateCacheKey();
None
string
•Paginate Method
Get a paginator for the query.
$stats = Stat::recentVisitors()->paginate();
-
perPage
[integer] -
columns
[array]
\Illuminate\Pagination\Paginator
•Get Pagination Count Method
Get the count of the total records for pagination.
$stats = Stat::recentVisitors()->paginate();
None
integer
•Simple Paginate Method
Get a paginator only supporting simple next and previous links.
This is more efficient on larger data-sets, etc.
$stats = Stat::recentVisitors()->simplePaginate();
-
perPage
[integer] -
columns
[array]
\Illuminate\Pagination\Paginator
•Exists Method
Determine if any rows exist for the current query.
$stats = Stat::recentVisitors()->exists();
None
bool
•Count Method
Retrieve the "count" result of the query.
$stats = Stat::recentVisitors()->count();
-
columns
[array]
integer
•New Query Method
Get a new instance of the stat query.
$statObj = Stat::recentVisitors();
...
$stats = $statObj->get();
...
$newStatObj = $statObj->newQuery();
-
columns
[array]
\Injic\LaravelStatcounter\Stat
•Raw Method
Create a raw query to the API. Accepts full url string, query portion of the url, or an array of parameters. Defaults to config defaults and the parameter defaults mentioned in their modifying methods.
$stats = Stat::raw('https://api.statcounter.com/stats?vn=3&s=keyword_analysis&pi=9917949&u=DaFlyinJ&t=1408580636')->get();
// - OR -
$stats = Stat::raw(['s' => 'keyword_analysis'])->get();
-
value
[mixed]
$this
•Columns Method
Reads query results for columns.
$columns = Stat::recentVisitors()->columns();
None
array
•Get Columns Method
Reads array for column values.
$stats = Stat::recentVisitors()->get();
$columns = Stat::getColumns($stats);
-
array
[array]
array