public function trackPage($page = null, $title = null, $hittype = null)
    {
        $allowedHitTypes = ['pageview', 'appview', 'event', 'transaction', 'item', 'social', 'exception', 'timing'];
        if ($hittype === null) {
            $hittype = $allowedHitTypes[0];
        }

        if (!in_array($hittype, $allowedHitTypes)) {
            return;
        }

        $trackingCode = "ga('send', 'pageview');";

        if ($page !== null || $title !== null || $hittype !== null) {
            $page = ($page === null) ? "window.location.protocol + '//' + window.location.hostname + window.location.pathname + window.location.search" : "'{$page}'";
            $title = ($title === null) ? "document.title" : "'{$title}'";

            $trackingCode = "ga('send', {'hitType': '{$hittype}', 'page': {$page}, 'title': {$title}});";
        }

        $this->trackingBag->add($trackingCode);
    }
public function trackPage($page = null, $title = null, $hittype = null)
    {
        $allowedHitTypes = ['pageview', 'appview', 'event', 'transaction', 'item', 'social', 'exception', 'timing'];
        if ($hittype === null) {
            $hittype = $allowedHitTypes[0];
        }

        if (!in_array($hittype, $allowedHitTypes)) {
            return;
        }

        $trackingCode = "ga('send', 'pageview');";

        if ($page !== null || $title !== null || $hittype !== null) {
            $page = ($page === null) ? "window.location.protocol + '//' + window.location.hostname + window.location.pathname + window.location.search" : "'{$page}'";
            $title = ($title === null) ? "document.title" : "'{$title}'";

            $trackingCode = "ga('send', {'hitType': '{$hittype}', 'page': {$page}, 'title': {$title}});";
        }

        $this->trackingBag->add($trackingCode);
    }
public function trackPage ( $ page = null , $ title = null , $ hittype = null ) { $ allowedHitTypes = [ 'pageview' , 'appview' , 'event' , 'transaction' , 'item' , 'social' , 'exception' , 'timing' ] ; if ( $ hittype === null ) { $ hittype = $ allowedHitTypes [ 0 ] ; } if ( ! in_array ( $ hittype , $ allowedHitTypes ) ) { return ; } $ trackingCode = "ga('send', 'pageview');" ; if ( $ page !== null || $ title !== null || $ hittype !== null ) { $ page = ( $ page === null ) ? "window.location.protocol + '//' + window.location.hostname + window.location.pathname + window.location.search" : "'{$page}'" ; $ title = ( $ title === null ) ? "document.title" : "'{$title}'" ; $ trackingCode = "ga('send', {'hitType': '{$hittype}', 'page': {$page}, 'title': {$title}});" ; } $ this -> trackingBag -> add ( $ trackingCode ) ; }
track an page view

@param null|string $page
@param null|string $title
@param null|string $hittype

@return void
track an page view