PHP code example of apix / log-tracker

1. Go to this page and download the library: Download apix/log-tracker 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/ */

    

apix / log-tracker example snippets


use Apix\Log;

$options = [
    'tid' => '<UA-XX-XX>',   // Tracking/Property ID (-generated one).
    //...                    // Any numbers of Google Analytics Parameters (see notes). 
];

$ga_logger = new GoogleAnalytics($options);
$ga_logger->setDeferred(true); // Enable batched mode (recommneded).

$dataToTrack = $ga_logger->getPage('http://foo.tld/...', 'Welcome page');
//$dataToTrack = $ga_logger->getEvent('category', 'action', 'label', 'value');
//$dataToTrack = $ga_logger->getSocial('action', 'network', 'target');
//$dataToTrack = $ga_logger->getException('description');
//$dataToTrack = $ga_logger->getApp('name', 'version', 'id');

$ga_logger->notice('GA Tracking', $dataToTrack);

use Apix\Log;

$dashbot_logger = new Dashbot('<API-Key');
//$dashbot_logger->setPlatform('facebook'); // 'generic' (default), 'slack', 'kik'.
//$dashbot_logger->setGlobalTag('myTag');   // Useful to combined metrics.

$messages_received = ["text" => "Hi, bot", "userId" => "..."];
$dataToTrack = $dashbot_logger->incoming($messages_received);
//$dataToTrack = $dashbot_logger->incoming($messages_received, "localTag"); // Override the global tag

$messages_sent = ["text" => "Hello, user", "userId" => "..."];
$dataToTrack = $logger->outgoing($messages_sent);

$dashbot_logger->info('Dashbot Tracking', $dataToTrack);