Download the PHP package themusicdev/analytics without Composer

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

TheMusicDev/Analytics

Tracking tags (Google Analytics 4, Umami) and any other scripts a site needs, for CakePHP 5 sites: rendered on production hosts only. A known provider turns on by itself when its environment variables are set. The plugin asks visitors for nothing and enforces no consent rule (see "Cookies and consent").

Status: the helper, the injection and the Google and Umami providers are built (A1–A3); not released yet. What is left is the real-world check in a first site (A4). Decisions and plan: docs/analytics-plugin-design.md. Not on Packagist yet.

Install

Configure

Known providers turn on from the environment. Set the variables (in the server's .env) and the provider's tag is printed; nothing else to configure except which hosts may render:

Provider key Environment variables On when
google (Google Analytics 4) GA_MEASUREMENT_ID it is G- plus letters and digits
umami UMAMI_WEBSITE_ID, UMAMI_SRC the ID is a UUID and UMAMI_SRC is an https URL

A provider with a missing or malformed value is silently off, so a typo in a server's .env cannot break pages. The environment variables never open a host: with no entry in hosts nothing renders, however many are set.

Override from app.php. Set a provider's block to use other values, or to false to turn it off for good; the other providers keep their defaults (tracking merges one level deep):

Host values win over config/app_default.php, where the defaults are env() calls. New providers are added to the plugin as a class plus a line in that file.

Use

Print the tags in your layout:

Load the helper once in AppView::initialize(): $this->addHelper('TheMusicDev/Analytics.Analytics');. Both methods return an empty string unless the request host is in Analytics.hosts, and the output is the same for every visitor, so pages stay cacheable.

What each provider prints: google is the Google Analytics 4 gtag.js snippet; umami is <script defer src=… data-website-id=…>. The config keys are measurementId (google) and websiteId + src (umami).

Injections are any script a site needs (a tag manager, a snippet): each entry has html or src (never both), an optional position (head, the default, renders before the tracking tags, or body-end), an optional order (lower first; ties keep their config order) and, for src, optional async / defer. They are code in your config, so a malformed entry or an unknown tracking provider key throws, on every host, so a typo is caught in development.

Cookies and consent

The plugin sends nothing on hosts you have not listed, but it does not ask visitors for consent and enforces no rule about it. Google Analytics sets cookies and needs prior consent for visitors in the EU and UK (and notice or opt-out in several US states); Umami, which uses no cookies, generally does not. Whether and how to ask is the site's responsibility.

Tests

The tests run against a tiny test application in tests/test_app. There is no database.

License

MIT, see LICENSE.


All versions of analytics with dependencies

PHP Build Version
Package Version
Requires php Version >=8.2
cakephp/cakephp Version ^5.2
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 themusicdev/analytics contains the following files

Loading the files please wait ...