项目作者: uxmz

项目描述 :
Google Analytics Measurement Protocol Client Implementation in PHP
高级语言: PHP
项目地址: git://github.com/uxmz/tracking.git
创建时间: 2016-07-08T10:22:03Z
项目社区:https://github.com/uxmz/tracking

开源协议:MIT License

下载


Google Analytics Measurement Protocol

Provides a Google Analytics Measurement Protocol implementation

Usage

Create a new tracker and then send events to google analytics by invoking the
tracker’s track_* methods like shown bellow

  1. $httpClient = new GuzzleHttp\Client(); // we use guzzle as http client to send hits to google analytics
  2. $logger = new \Monolog\Logger('general'); // You can set this to any logger adhering to the Psr\Log standard
  3. $trackerOptions = [
  4. "applicationName" => "Test",
  5. "webTrackingId" => 'UA-XXXX-Y', // initialize with you analytics property ID
  6. "appTrackingId" => 'UA-XXXX-Y', // initialize with you analytics property ID
  7. "batching" => false,
  8. "debug" => true,
  9. ];
  10. $tracker = new Tracker($httpClient, $logger, $trackerOptions);
  11. $tracker->trackPageView('user-cid', 'example.com', '/', 'home');

Notes

  • Exceptions tracking doesn’t work on a Normal Tracker, it requires an
    Application Tracker, so please make sure when you create an instance for the
    tracker you include an appTrackingId to be used for sending events.

    If you don’t, the tracker will default to the normal tracker and you won’t be
    able to see anything in your dashboard.

Docs Generation

not working any more

  1. # 1. Run phpdoc command
  2. vendor/bin/phpdoc -d src -t -docs --template="xml"
  3. # 2. Next, run phpdocmd:
  4. vendor/bin/phpdocmd -docs/structure.xml docs
  5. # 3. delete temporary XML docs
  6. rm -fR -docs