public function getNodeStat(NodeInterface $node, ControllerContext $controllerContext, $statIdentifier, \DateTime $startDate, \DateTime $endDate)
    {
        $this->analytics->requireAuthentication();
        if (!isset($this->statsSettings[$statIdentifier])) {
            throw new \InvalidArgumentException(sprintf('Unknown stat identifier "%s"', $statIdentifier), 1416917316);
        }
        $statConfiguration = $this->statsSettings[$statIdentifier];
        $siteConfiguration = $this->getSiteConfigurationByNode($node);

        $startDateFormatted = $startDate->format('Y-m-d');
        $endDateFormatted = $endDate->format('Y-m-d');

        $nodeUri = $this->getLiveNodeUri($node, $controllerContext);
        $filters = 'ga:pagePath==' . $nodeUri->getPath() . ';ga:hostname==' . $nodeUri->getHost();
        $parameters = [
            'filters' => $filters
        ];
        if (isset($statConfiguration['dimensions'])) {
            $parameters['dimensions'] = $statConfiguration['dimensions'];
        }
        if (isset($statConfiguration['sort'])) {
            $parameters['sort'] = $statConfiguration['sort'];
        }
        if (isset($statConfiguration['max-results'])) {
            $parameters['max-results'] = $statConfiguration['max-results'];
        }
        $gaResult = $this->analytics->data_ga->get(
            'ga:' . $siteConfiguration->getProfileId(),
            $startDateFormatted,
            $endDateFormatted,
            $statConfiguration['metrics'],
            $parameters
        );

        return new DataResult($gaResult);
    }
public function getNodeStat(NodeInterface $node, ControllerContext $controllerContext, $statIdentifier, \DateTime $startDate, \DateTime $endDate)
    {
        $this->analytics->requireAuthentication();
        if (!isset($this->statsSettings[$statIdentifier])) {
            throw new \InvalidArgumentException(sprintf('Unknown stat identifier "%s"', $statIdentifier), 1416917316);
        }
        $statConfiguration = $this->statsSettings[$statIdentifier];
        $siteConfiguration = $this->getSiteConfigurationByNode($node);

        $startDateFormatted = $startDate->format('Y-m-d');
        $endDateFormatted = $endDate->format('Y-m-d');

        $nodeUri = $this->getLiveNodeUri($node, $controllerContext);
        $filters = 'ga:pagePath==' . $nodeUri->getPath() . ';ga:hostname==' . $nodeUri->getHost();
        $parameters = [
            'filters' => $filters
        ];
        if (isset($statConfiguration['dimensions'])) {
            $parameters['dimensions'] = $statConfiguration['dimensions'];
        }
        if (isset($statConfiguration['sort'])) {
            $parameters['sort'] = $statConfiguration['sort'];
        }
        if (isset($statConfiguration['max-results'])) {
            $parameters['max-results'] = $statConfiguration['max-results'];
        }
        $gaResult = $this->analytics->data_ga->get(
            'ga:' . $siteConfiguration->getProfileId(),
            $startDateFormatted,
            $endDateFormatted,
            $statConfiguration['metrics'],
            $parameters
        );

        return new DataResult($gaResult);
    }
public function getNodeStat ( NodeInterface $ node , ControllerContext $ controllerContext , $ statIdentifier , \ DateTime $ startDate , \ DateTime $ endDate ) { $ this -> analytics -> requireAuthentication ( ) ; if ( ! isset ( $ this -> statsSettings [ $ statIdentifier ] ) ) { throw new \ InvalidArgumentException ( sprintf ( 'Unknown stat identifier "%s"' , $ statIdentifier ) , 1416917316 ) ; } $ statConfiguration = $ this -> statsSettings [ $ statIdentifier ] ; $ siteConfiguration = $ this -> getSiteConfigurationByNode ( $ node ) ; $ startDateFormatted = $ startDate -> format ( 'Y-m-d' ) ; $ endDateFormatted = $ endDate -> format ( 'Y-m-d' ) ; $ nodeUri = $ this -> getLiveNodeUri ( $ node , $ controllerContext ) ; $ filters = 'ga:pagePath==' . $ nodeUri -> getPath ( ) . ';ga:hostname==' . $ nodeUri -> getHost ( ) ; $ parameters = [ 'filters' => $ filters ] ; if ( isset ( $ statConfiguration [ 'dimensions' ] ) ) { $ parameters [ 'dimensions' ] = $ statConfiguration [ 'dimensions' ] ; } if ( isset ( $ statConfiguration [ 'sort' ] ) ) { $ parameters [ 'sort' ] = $ statConfiguration [ 'sort' ] ; } if ( isset ( $ statConfiguration [ 'max-results' ] ) ) { $ parameters [ 'max-results' ] = $ statConfiguration [ 'max-results' ] ; } $ gaResult = $ this -> analytics -> data_ga -> get ( 'ga:' . $ siteConfiguration -> getProfileId ( ) , $ startDateFormatted , $ endDateFormatted , $ statConfiguration [ 'metrics' ] , $ parameters ) ; return new DataResult ( $ gaResult ) ; }
Get metrics and dimension values for a configured stat

TODO Catch "(403) Access Not Configured" (e.g. IP does not match)

@param NodeInterface $node
@param ControllerContext $controllerContext
@param string $statIdentifier
@param \DateTime $startDate
@param \DateTime $endDate
@return DataResult
@throws MissingConfigurationException
@throws AnalyticsNotAvailableException
Get metrics and dimension values for a configured stat