Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions src/Widop/GoogleAnalytics/Query.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ class Query
/** @var string */
protected $callback;

/** @var string */
protected $samplingLevel;

/**
* Creates a google analytics query.
*
Expand Down Expand Up @@ -515,6 +518,40 @@ public function setCallback($callback)
return $this;
}

/**
* Checks the google analytics query for a sampling level.
*
* @return boolean TRUE if the google analytics query has a sampling level else FALSE.
*/
public function hasSamplingLevel()
{
return !empty($this->samplingLevel);
}

/**
* Gets the google analytics query sampling level.
*
* @return string The google analytics sampling level ('FASTER', DEFAULT', 'HIGHER_PRECISION').
*/
public function getSamplingLevel()
{
return $this->samplingLevel;
}

/**
* Sets the google analytics query sampling level.
*
* @param string $samplingLevel The google analytics query sampling level ('FASTER', DEFAULT', 'HIGHER_PRECISION').
*
* @return \Widop\GoogleAnalytics\Query The query.
*/
public function setSamplingLevel($samplingLevel)
{
$this->samplingLevel = $samplingLevel;

return $this;
}

/**
* Builds the query.
*
Expand All @@ -533,6 +570,9 @@ public function build($accessToken)
'start-index' => $this->getStartIndex(),
'max-results' => $this->getMaxResults(),
);
if ($this->hasSamplingLevel()) {
$query['samplingLevel'] = $this->getSamplingLevel();
}

if ($this->hasSegment()) {
$query['segment'] = $this->getSegment();
Expand Down