https://github.com/matomo-org/matomo-php-tracker
PHP Client for Matomo Analytics Tracking API
https://github.com/matomo-org/matomo-php-tracker
matomo php php-client
Last synced: 14 days ago
JSON representation
PHP Client for Matomo Analytics Tracking API
- Host: GitHub
- URL: https://github.com/matomo-org/matomo-php-tracker
- Owner: matomo-org
- License: bsd-3-clause
- Created: 2014-06-24T22:31:52.000Z (almost 11 years ago)
- Default Branch: master
- Last Pushed: 2025-01-22T13:59:09.000Z (3 months ago)
- Last Synced: 2025-04-09T21:29:19.715Z (19 days ago)
- Topics: matomo, php, php-client
- Language: PHP
- Homepage:
- Size: 301 KB
- Stars: 215
- Watchers: 29
- Forks: 84
- Open Issues: 14
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# PHP Client for Matomo Analytics Tracking API
The PHP Tracker Client provides all features of the [Matomo Javascript Tracker](https://developer.matomo.org/api-reference/tracking-javascript), such as Ecommerce Tracking, Custom Variables, Event Tracking and more.
## Documentation and examples
Check out our [Matomo-PHP-Tracker developer documentation](https://developer.matomo.org/api-reference/PHP-Piwik-Tracker) and [Matomo Tracking API guide](https://matomo.org/docs/tracking-api/).```php
// Required variables
$matomoSiteId = 6; // Site ID
$matomoUrl = "https://example.tld"; // Your matomo URL
$matomoToken = ""; // Your authentication token// Optional variable
$matomoPageTitle = ""; // The title of the page// Load object
require_once("MatomoTracker.php");// Matomo object
$matomoTracker = new MatomoTracker((int)$matomoSiteId, $matomoUrl);// Set authentication token
$matomoTracker->setTokenAuth($matomoToken);// Track page view
$matomoTracker->doTrackPageView($matomoPageTitle);
```## Requirements:
* JSON extension (json_decode, json_encode)
* cURL or stream extension (to issue the HTTPS request to Matomo)## Installation
### Composer
```
composer require matomo/matomo-php-tracker
```### Manually
Alternatively, you can download the files and require the Matomo tracker manually:
```
require_once("MatomoTracker.php");
```## License
Released under the [BSD License](https://opensource.org/licenses/BSD-3-Clause)