Download the PHP package pagemachine/matomo-tracking without Composer

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

Matomo Tracking API

Server-side tracking of actions (e.g. page views) in Matomo using the Matomo Tracking HTTP API.

Features

Privacy by design

Installation

composer require pagemachine/matomo-tracking

Usage

Actions can be tracked with the Matomo class. Make sure you have implementations for UriFactoryInterface, RequestFactoryInterface, ClientInterface and LoggerInterface.

You should configure the HTTP client with a sane timeout. This ensures pages load quickly in case a Matomo instance is not responding. Tracking will be skipped in this case.

In case of most frameworks the dependency injection container will cover most dependencies and you only need to manually configure the URL of your Matomo instance. E.g. with Symfony:

Then have Matomo injected:

Alternatively use standalone solutions like guzzlehttp/guzzle, guzzlehttp/psr7 and some useful logger or the PSR NullLogger:

Server requests

A PSR-7 ServerRequestInterface can directly be tracked as page view:

As shown the custom matomo.attributes request attribute can be set for tracking attributes.

By default URLs (current, referrer) and client info (user agent, language) are determined from the server request.

Actions

Aside from PSR-7 server requests, actions not directly related to a request can also be tracked. Use the ActionFactoryInterface (frameworks) or the ActionFactory (standalone) to track an action with attributes:

You can also create an action from a PSR-7 ServerRequestInterface if desired:

Action factories

If there are additional attributes which should be added to actions by default, you can add a custom ActionFactoryInterface. This should wrap or decorate the default ActionFactory to ensure all default attributes are added:

This pattern can be used to add the mandatory SiteId attribute to all tracked actions.

Attributes

Attributes contain tracking values and cover one or more of the Matomo Tracking HTTP API parameters:

Attribute Matomo API parameters
ActionName action_name
ApiVersion (*) apiv
AuthToken token_auth
BotTracking bots
CustomAction ca
Download download, url, ca
DownloadUrl download
Language lang
NoResponse (*) send_image
Random (*) rand
Recording (*) rec
ReferrerUrl urlref
Search search, search_count, search_cat, ca
SearchCategory search_cat
SearchKeyword search
SearchResultCount search_count
SiteId idsite
Url url
UserAgent ua
VisitorId _id
VisitorIpAddress cip

(Attributes marked with * are added internally and always sent.)

You must at least add a SiteId attribute for tracking in Matomo. All other attributes may be used on demand.

Some attributes like VisitorIpAddress require an auth token which must be provided with the AuthToken attribute. See Matomo Tracking HTTP API: Other parameters for details when an auth token is required.

Custom attributes

Custom attributes can be added by implementing the AttributeInterface:

The keys of the iterable (array, \Generator, etc.) returned by toParameters() must be parameters of the Matomo Tracking HTTP API.


All versions of matomo-tracking with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1
psr/http-client Version ^1.0
psr/http-factory Version ^1.0
psr/http-message Version ^1.0 || ^2.0
psr/log Version ^1.0 || ^2.0 || ^3.0
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 pagemachine/matomo-tracking contains the following files

Loading the files please wait ....