Google Analytics Measurement Protocol library implementation for PHP
$classGamp = new Gamp\Gamp();
$cGeneral = new \Gamp\PayloadParamGroups\General();
$cGeneral->setV(1);
$cGeneral->setTid('UA-27773588-3');
$classGamp->addGroup($cGeneral);
$cUser = new \Gamp\PayloadParamGroups\User();
$cUser->setCid($cUser->getCidNumber());
$classGamp->addGroup($cUser);
$cHit = new \Gamp\PayloadParamGroups\Hit();
$cHit->setT('event'); //Event type
$classGamp->addGroup($cHit);
$cEvent = new \Gamp\PayloadParamGroups\Event();
$cEvent->setEc('Download');
$cEvent->setEa('Some product name');
$cEvent->setEl('Some URL');
$classGamp->addGroup($cEvent);
$cCustomDimension = new \Gamp\PayloadParamGroups\CustomDimension();
$cCustomDimension->setCd('1', 'TEST-001-A');
$cCustomDimension->setCd('2', 'Some product name');
$cCustomDimension->setCd('3', 'Some URL');
$classGamp->addGroup($cCustomDimension);
$classGamp->setRequestType('POST');
$classGamp->setFiltered(true);
$classGamp->setRequestProtocol('SSL');
$classGamp->track();