diff --git a/src/Racecore/GATracking/Tracking/AbstractTracking.php b/src/Racecore/GATracking/Tracking/AbstractTracking.php index e6c1c59..6650862 100755 --- a/src/Racecore/GATracking/Tracking/AbstractTracking.php +++ b/src/Racecore/GATracking/Tracking/AbstractTracking.php @@ -128,6 +128,9 @@ abstract class AbstractTracking private $customPayload = array(); + // event queue time difference + private $queueTime; + /** * Add Custom Tracking Payload Data send to Google * @param $key @@ -196,6 +199,9 @@ public function getPackage() // content experiments 'xid' => $this->experimentID, 'xvar' => $this->experimentVariant, + + // optional + 'qt' => $this->queueTime, )); $package = $this->addCustomParameters($package); @@ -209,6 +215,19 @@ public function getPackage() return $package; } + /** + * Set the Tracking Processing Time to pass the qt param within this tracking request + * ATTENTION!: Values greater than four hours may lead to hits not being processed. + * + * https://developers.google.com/analytics/devguides/collection/protocol/v1/parameters#qt + * + * @param $milliseconds + */ + public function setQueueTime($milliseconds) + { + $this->queueTime = $milliseconds; + } + /** * Mark the Hit as Non Interactive * diff --git a/test/Racecore/GATracking/Tracking/TrackingTest.php b/test/Racecore/GATracking/Tracking/TrackingTest.php new file mode 100644 index 0000000..73b4120 --- /dev/null +++ b/test/Racecore/GATracking/Tracking/TrackingTest.php @@ -0,0 +1,26 @@ +setEventCategory('foo'); + $event->setEventAction('bar'); + $event->setQueueTime($queueTime); + + $package = $event->getPackage(); + $this->assertEquals($queueTime, $package['qt']); + } +}