Download the PHP package analytical42/googleanalyticscookie without Composer

On this page you can find all versions of the php package analytical42/googleanalyticscookie. 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 googleanalyticscookie

HTTP Cookie for Google Analytics

Makes Google Analytics use a server side HTTP cookie instead of the default javascript cookie set with document.cookie.

Background

Browser vendors are increasingly limiting the ability to use and persist cookies set with document.cookie. Among other things, this impacts Google Analytics' ability to identify and recognise e.g. returning users.

Solution

As of yet, first party cookies that are set in the HTTP header are not affected by steps taken by browser vendors. As such, it's possible to preserve data quality in Google Analytics by using a HTTP cookie. This package does that.

The library currently works by storing the Client ID in a custom HTTP Only cookie (_ga_storage). Whenever a user visits the website, the library first checks this cookie for a Client ID. If it's not found, a Client ID is searched for in the default GA cookie (_ga), and if this isn't found either, a new Client ID is generated.

The Client ID is then stored in the _ga_storage cookie with a two year expiration time. Secondly, the Client ID is also written to the _ga cookie which is then used by Google Analytics.

What's not included?

At the moment, cross domain tracking is not supported. In order to support that, it's necessary to implement a browser fingerprint and since PHP can't read what plugins are installed in the browser, this would require javascript to be used which would complicate the implementation.

Installation

You can install the package through Composer:

If your project does not use Composer, it's possible to just download the Cookie.php file directly, save it in your project, require it and instantiate.

Usage

By default, you can run the package without any configurations when bootstrapping your application. Simply instantiate the class:

Next, make sure that Google Analytics doesn't automatically update and overwrite the cookie. Simply set the cookieUpdate field to false using GTM.

And that's it!

Configuration

If required, it's possible to manually set the cookie name and cookie domain when instantiating:

Note: If you set the cookie name and/or domain here, you need to apply the same changes to your Google Analytics snippet implementation; the configuration here does not change the configuration of Google Analytics.

Default parameters

By default, the package will use Google Analytics' default cookie name (_ga). In addition, if you don't specify a domain, the package will use the value of $_SERVER['HTTP_HOST'].

The last option indicates whether or not to write a secure cookie (secure = true, unsecure = false).

Credits

The solution in this library is inspired by thoughts, code examples and more from:

License

The MIT License (MIT)

Copyright (c) 2019 Phillip Studinski

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.


All versions of googleanalyticscookie with dependencies

PHP Build Version
Package Version
Requires php Version >=7
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 analytical42/googleanalyticscookie contains the following files

Loading the files please wait ....