Download the PHP package eklundkristoffer/laravel-analytics without Composer

On this page you can find all versions of the php package eklundkristoffer/laravel-analytics. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package laravel-analytics

Retrieve data from Google Analytics

Latest Version Build Status Quality Score SensioLabsInsight StyleCI Total Downloads

Using this package you can easily retrieve data from Google Analytics.

Here are a few examples of the provided methods:

Most methods will return an \Illuminate\Support\Collection object containing the results.

Spatie is a webdesign agency in Antwerp, Belgium. You'll find an overview of all our open source projects on our website.

If you're using v1 of this package, please refer to an older version of this readme for the installation and usage guide.

Postcardware

You're free to use this package (it's MIT-licensed), but if it makes it to your production environment you are required to send us a postcard from your hometown, mentioning which of our package(s) you are using.

Our address is: Spatie, Samberstraat 69D, 2060 Antwerp, Belgium.

All postcards are published on our website.

Installation

This package can be installed through Composer.

You must install this service provider.

This package also comes with a facade, which provides an easy way to call the the class.

Optionally, you can publish the config file of this package with this command:

The following config file will be published in config/analytics.php

How to obtain the credentials to communicate with Google Analytics

Getting credentials

The first thing you’ll need to do is to get some credentials to use Google API’s. I’m assuming that you’ve already created a Google account and are signed in. Head over to Google API’s site and click "Select a project" in the header.

1

Next up we must specify which API’s the project may consume. In the list of available API’s click "Google Analytics API". On the next screen click "Enable".

2

Now that you’ve created a project that has access to the Analytics API it’s time to download a file with these credentials. Click "Credentials" in the sidebar. You’ll want to create a "Service account key".

3

On the next screen you can give the service account a name. You can name it anything you’d like. In the service account id you’ll see an email address. We’ll use this email address later on in this guide. Select "JSON" as the key type and click "Create" to download the JSON file.

4

Save the json inside your Laravel project at the location specified in the service_account_credentials_json key of the config file of this package. Because the json file contains potentially sensitive information I don't recommend committing it to your git repository.

Granting permissions to your Analytics property

I'm assuming that you've already created a Analytics account on the Analytics site. Go to "User management" in the Admin-section of the property.

5

On this screen you can grant access to the email address found in the client_email key from the json file you download in the previous step. Read only access is enough.

6

Getting the view id

The last thing you'll have to do is fill in the view_id in the config file. You can get the right value on the Analytics site. Go to "View setting" in the Admin-section of the property.

7

You'll need the View ID displayed there.

8

Usage

When the installation is done you can easily retrieve Analytics data. Nearly all methods will return an Illuminate\Support\Collection-instance.

Here is an example to retrieve visitors and pageview data for the current day and the last seven days.

$analyticsData is a Collection in which each item is an array that holds keys date, visitors and pageViews

If you want to have more control over the period you want to fetch data for, you can pass a startDate and an endDate to the period object.

Provided methods

Visitors and pageviews

The function returns a Collection in which each item is an array that holds keys date, visitors, pageTitle and pageViews.

Total visitors and pageviews

The function returns a Collection in which each item is an array that holds keys date, visitors, and pageViews.

Most visited pages

The function returns a Collection in which each item is an array that holds keys url, pageTitle and pageViews.

Top referrers

The function returns a Collection in which each item is an array that holds keys url and pageViews.

Top browsers

The function returns a Collection in which each item is an array that holds keys browser and sessions.

All other Google Analytics queries

To perform all other queries on the Google Analytics resource use performQuery. Google's Core Reporting API provides more information on which metrics and dimensions might be used.

You can get access to the underlying Google_Service_Analytics object:

Testing

Run the tests with:

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email [email protected] instead of using the issue tracker.

Credits

About Spatie

Spatie is a webdesign agency in Antwerp, Belgium. You'll find an overview of all our open source projects on our website.

License

The MIT License (MIT). Please see License File for more information.


All versions of laravel-analytics with dependencies

PHP Build Version
Package Version
Requires php Version ^7.0
google/apiclient Version ^2.0
illuminate/contracts Version 5.4.*|5.5.*
illuminate/support Version 5.4.*|5.5.*
madewithlove/illuminate-psr-cache-bridge Version ^1.0
nesbot/carbon Version ^1.21
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package eklundkristoffer/laravel-analytics contains the following files

Loading the files please wait ....