1. Go to this page and download the library: Download betacie/google-analytics library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
betacie / google-analytics example snippets
use Betacie\Google\Tracker\EventTracker;
use Betacie\Google\Storage\ArrayStorage;
$storage = new ArrayStorage();
$tracker = new EventTracker($storage);
// You can track many event thanks to Storage classes, you can choose ArrayStorage or SessionStorage
// SessionStorage will be persistant until you render your tracking code.
$tracker->trackEvent([
'category' => 'Registration',
'action' => 'Confirmed',
'label' => 'user-1',
]);
$tracker->trackEvent([
'category' => 'Registration',
'action' => 'Completed',
'label' => 'user-1',
]);
// render() will print the tracking code and clear all event already store, this prevent duplicate tracking
echo $tracker->render();
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.