PHP Class Piwik\Plugins\Insights\API

Inheritance: extends Piwik\Plugin\API
Show file Open project: piwik/piwik Class Usage Examples

Public Methods

Method Description
__construct ( Model $model )
canGenerateInsights ( string $date, string $period ) : boolean Detects whether insights can be generated for this date/period combination or not.
getInsights ( integer $idSite, string $period, string $date, string $reportUniqueId, boolean | string $segment = false, integer $limitIncreaser = 5, integer $limitDecreaser = 5, string $filterBy = '', integer $minImpactPercent = 2, integer $minGrowthPercent = 20, integer $comparedToXPeriods = 1, string $orderBy = 'absolute' ) : DataTable Generates insights by comparing the report for a given date/period with a different date and calculating the difference. The API can exclude rows which growth is not good enough or did not have enough impact.
getInsightsOverview ( integer $idSite, string $period, string $date, boolean | string $segment = false ) : Piwik\DataTable\Map Generates insights for a set of reports. Plugins can add their own reports to be included in the insights overview by listening to the {@hook Insights.addReportToOverview} event.
getMoversAndShakers ( integer $idSite, string $period, string $date, string $reportUniqueId, boolean | string $segment = false, integer $comparedToXPeriods = 1, integer $limitIncreaser = 4, integer $limitDecreaser = 4 ) : DataTable Detects the movers and shakers of a given date / report combination. A mover and shakers has an higher impact than other rows on average. For instance if a sites pageviews increase by 10% a page that increased by 40% at the same time contributed significantly more to the success than the average of 10%.
getMoversAndShakersOverview ( integer $idSite, string $period, string $date, boolean | string $segment = false ) : Piwik\DataTable\Map Detects the movers and shakers for a set of reports. Plugins can add their own reports to be included in this overview by listening to the {@hook Insights.addReportToOverview} event.

Private Methods

Method Description
checkReportIsValid ( $report )
generateOverviewReport ( $method, $idSite, $period, $date, $segment, array $defaultParams )
getOverviewReports ( )
requestApiMethod ( $method, $idSite, $period, $date, $reportId, $segment, $additionalParams )

Method Details

__construct() public method

public __construct ( Model $model )
$model Model

canGenerateInsights() public method

Detects whether insights can be generated for this date/period combination or not.
public canGenerateInsights ( string $date, string $period ) : boolean
$date string eg 'today', '2012-12-12'
$period string eg 'day' or 'week'
return boolean

getInsights() public method

Generates insights by comparing the report for a given date/period with a different date and calculating the difference. The API can exclude rows which growth is not good enough or did not have enough impact.
public getInsights ( integer $idSite, string $period, string $date, string $reportUniqueId, boolean | string $segment = false, integer $limitIncreaser = 5, integer $limitDecreaser = 5, string $filterBy = '', integer $minImpactPercent = 2, integer $minGrowthPercent = 20, integer $comparedToXPeriods = 1, string $orderBy = 'absolute' ) : DataTable
$idSite integer
$period string
$date string
$reportUniqueId string eg 'Actions_getPageUrls'. An id like 'Goals_getVisitsUntilConversion_idGoal--4' works as well.
$segment boolean | string
$limitIncreaser integer Value '0' ignores all increasers
$limitDecreaser integer Value '0' ignores all decreasers
$filterBy string By default all rows will be ignored. If given only 'movers', 'new' or 'disappeared' will be returned.
$minImpactPercent integer The minimum impact in percent. Eg '2%' of 1000 visits means the change / increase / decrease has to be at least 20 visits. Usually the '2%' are based on the total amount of visits but for reports having way less visits the metric total is used. Eg A page has 1000 visits but only 100 visits having keywords. In this case a minimum impact of '2%' evaluates to 2 and not 20.
$minGrowthPercent integer The amount of percent a row has to increase or decrease at least compared to the previous period. If value is '20' the growth has to be either at least '+20%' or '-20%' and lower.
$comparedToXPeriods integer The report will be compared to X periods before.
$orderBy string Orders the rows by 'absolute', 'relative' or 'importance'.
return Piwik\DataTable

getInsightsOverview() public method

Generates insights for a set of reports. Plugins can add their own reports to be included in the insights overview by listening to the {@hook Insights.addReportToOverview} event.
public getInsightsOverview ( integer $idSite, string $period, string $date, boolean | string $segment = false ) : Piwik\DataTable\Map
$idSite integer
$period string
$date string
$segment boolean | string
return Piwik\DataTable\Map A map containing a dataTable for each insight report. See {@link getInsights()} for more information

getMoversAndShakers() public method

Detects the movers and shakers of a given date / report combination. A mover and shakers has an higher impact than other rows on average. For instance if a sites pageviews increase by 10% a page that increased by 40% at the same time contributed significantly more to the success than the average of 10%.
public getMoversAndShakers ( integer $idSite, string $period, string $date, string $reportUniqueId, boolean | string $segment = false, integer $comparedToXPeriods = 1, integer $limitIncreaser = 4, integer $limitDecreaser = 4 ) : DataTable
$idSite integer
$period string
$date string
$reportUniqueId string eg 'Actions_getPageUrls'. An id like 'Goals_getVisitsUntilConversion_idGoal--4' works as well.
$segment boolean | string
$comparedToXPeriods integer
$limitIncreaser integer Value '0' ignores all increasers
$limitDecreaser integer Value '0' ignores all decreasers
return Piwik\DataTable

getMoversAndShakersOverview() public method

Detects the movers and shakers for a set of reports. Plugins can add their own reports to be included in this overview by listening to the {@hook Insights.addReportToOverview} event.
public getMoversAndShakersOverview ( integer $idSite, string $period, string $date, boolean | string $segment = false ) : Piwik\DataTable\Map
$idSite integer
$period string
$date string
$segment boolean | string
return Piwik\DataTable\Map A map containing a dataTable for each movers and shakers report. See {@link getMoversAndShakers()} for more information