PHP Класс Piwik\Plugins\Goals\API

If you are tracking Ecommerce orders and products on your site, the functions "getItemsSku", "getItemsName" and "getItemsCategory" will return the list of products purchased on your site, either grouped by Product SKU, Product Name or Product Category. For each name, SKU or category, the following metrics are returned: Total revenue, Total quantity, average price, average quantity, number of orders (or abandoned carts) containing this product, number of visits on the Product page, Conversion rate. By default, these functions return the 'Products purchased'. These functions also accept an optional parameter &abandonedCarts=1. If the parameter is set, it will instead return the metrics for products that were left in an abandoned cart therefore not purchased. The API also lets you request overall Goal metrics via the method "get": Conversions, Visits with at least one conversion, Conversion rate and Revenue. If you wish to request specific metrics about Ecommerce goals, you can set the parameter &idGoal=ecommerceAbandonedCart to get metrics about abandoned carts (including Lost revenue, and number of items left in the cart) or &idGoal=ecommerceOrder to get metrics about Ecommerce orders (number of orders, visits with an order, subtotal, tax, shipping, discount, revenue, items ordered) See also the documentation about Tracking Goals in Piwik.
Наследование: extends Piwik\Plugin\API
Показать файл Открыть проект Примеры использования класса

Открытые методы

Метод Описание
addGoal ( integer $idSite, string $name, string $matchAttribute, string $pattern, string $patternType, boolean $caseSensitive = false, boolean | float $revenue = false, boolean $allowMultipleConversionsPerVisit = false, string $description = '' ) : integer Creates a Goal for a given website.
deleteGoal ( integer $idSite, integer $idGoal ) : void Soft deletes a given Goal.
get ( integer $idSite, string $period, string $date, boolean $segment = false, boolean | integer $idGoal = false, array $columns = [] ) : DataTable Returns Goals data.
getConversionRate ( $idSite, $period, $date, $segment = false, $idGoal = false )
getConversions ( $idSite, $period, $date, $segment = false, $idGoal = false )
getDaysToConversion ( integer $idSite, string $period, string $date, string | boolean $segment = false, integer | boolean $idGoal = false ) : false | DataTable Gets a DataTable that maps ranges of days to the number of conversions that occurred within those ranges, for the specified site, date range, segment and goal.
getGoal ( integer $idSite, integer $idGoal ) : array Return a single goal.
getGoals ( string | array $idSite ) : array Returns all Goals for a given website, or list of websites
getItemsCategory ( $idSite, $period, $date, $abandonedCarts = false, $segment = false )
getItemsName ( $idSite, $period, $date, $abandonedCarts = false, $segment = false )
getItemsSku ( $idSite, $period, $date, $abandonedCarts = false, $segment = false )
getMetrics ( $idSite, $period, $date, $segment = false, $idGoal = false, $columns = [] ) Similar to {@link get()} but does not return any metrics for new and returning visitors. It won't apply any segment by default. This method is deprecated from the API as it is only there to make the implementation of the actual {@link get()} method easy.
getNbVisitsConverted ( $idSite, $period, $date, $segment = false, $idGoal = false )
getRevenue ( $idSite, $period, $date, $segment = false, $idGoal = false )
getVisitsUntilConversion ( integer $idSite, string $period, string $date, string | boolean $segment = false, integer | boolean $idGoal = false ) : boolean | DataTable Gets a DataTable that maps ranges of visit counts to the number of conversions that occurred on those visits for the specified site, date range, segment and goal.
updateGoal ( integer $idSite, integer $idGoal, $name, $matchAttribute, string $pattern, string $patternType, boolean $caseSensitive = false, boolean | float $revenue = false, boolean $allowMultipleConversionsPerVisit = false, string $description = '' ) : void Updates a Goal description.

Защищенные методы

Метод Описание
appendSegment ( $segment, $segmentToAppend )
convertSpecialGoalIds ( string | integer $idGoal ) : integer Helper function that checks for special string goal IDs and converts them to their integer equivalents.
enrichItemsDataTableWithItemsViewMetrics ( $dataTable, $idSite, $period, $date, $segment, $idSubtable )
enrichItemsTableWithViewMetrics ( $dataTable, $recordName, $idSite, $period, $date, $segment ) Enhances the dataTable with Items attributes found in the Custom Variables report.
getGoalSpecificDataTable ( string $recordName, integer | string $idSite, string $period, string $date, string $segment, integer | boolean $idGoal ) : false | DataTable Utility method that retrieve an archived DataTable for a specific site, date range, segment and goal. If not goal is specified, this method will retrieve and sum the data for every goal.
getItems ( $recordName, $idSite, $period, $date, $abandonedCarts, $segment ) Returns a datatable of Items SKU/name or categories and their metrics If $abandonedCarts set to 1, will return items abandoned in carts. If set to 0, will return items ordered
getNumeric ( $idSite, $period, $date, $segment, $toFetch )
renameNotDefinedRow ( $dataTable, $notDefinedStringPretty )

Приватные методы

Метод Описание
checkDescription ( $description )
checkName ( $name )
checkPattern ( $pattern )
checkPatternIsValid ( $patternType, $pattern, $matchAttribute )
formatGoal ( $goal )
getCacheId ( $idSite )
getGoalsInfoStaticCache ( )
getModel ( )

Описание методов

addGoal() публичный Метод

Creates a Goal for a given website.
public addGoal ( integer $idSite, string $name, string $matchAttribute, string $pattern, string $patternType, boolean $caseSensitive = false, boolean | float $revenue = false, boolean $allowMultipleConversionsPerVisit = false, string $description = '' ) : integer
$idSite integer
$name string
$matchAttribute string 'url', 'title', 'file', 'external_website', 'manually', 'event_action', 'event_category' or 'event_name'
$pattern string eg. purchase-confirmation.htm
$patternType string 'regex', 'contains', 'exact'
$caseSensitive boolean
$revenue boolean | float If set, default revenue to assign to conversions
$allowMultipleConversionsPerVisit boolean By default, multiple conversions in the same visit will only record the first conversion. If set to true, multiple conversions will all be recorded within a visit (useful for Ecommerce goals)
$description string
Результат integer ID of the new goal

appendSegment() защищенный Метод

protected appendSegment ( $segment, $segmentToAppend )

convertSpecialGoalIds() защищенный статический Метод

Checks for the following values: Piwik::LABEL_ID_GOAL_IS_ECOMMERCE_ORDER Piwik::LABEL_ID_GOAL_IS_ECOMMERCE_CART
protected static convertSpecialGoalIds ( string | integer $idGoal ) : integer
$idGoal string | integer The goal id as an integer or a special string.
Результат integer The numeric goal id.

deleteGoal() публичный Метод

Stats data in the archives will still be recorded, but not displayed.
public deleteGoal ( integer $idSite, integer $idGoal ) : void
$idSite integer
$idGoal integer
Результат void

enrichItemsDataTableWithItemsViewMetrics() защищенный Метод

protected enrichItemsDataTableWithItemsViewMetrics ( $dataTable, $idSite, $period, $date, $segment, $idSubtable )

enrichItemsTableWithViewMetrics() защищенный Метод

Enhances the dataTable with Items attributes found in the Custom Variables report.
protected enrichItemsTableWithViewMetrics ( $dataTable, $recordName, $idSite, $period, $date, $segment )
$dataTable
$recordName
$idSite
$period
$date
$segment

get() публичный Метод

Returns Goals data.
public get ( integer $idSite, string $period, string $date, boolean $segment = false, boolean | integer $idGoal = false, array $columns = [] ) : DataTable
$idSite integer
$period string
$date string
$segment boolean
$idGoal boolean | integer
$columns array Array of metrics to fetch: nb_conversions, conversion_rate, revenue
Результат Piwik\DataTable

getConversionRate() публичный Метод

public getConversionRate ( $idSite, $period, $date, $segment = false, $idGoal = false )

getConversions() публичный Метод

public getConversions ( $idSite, $period, $date, $segment = false, $idGoal = false )

getDaysToConversion() публичный Метод

Gets a DataTable that maps ranges of days to the number of conversions that occurred within those ranges, for the specified site, date range, segment and goal.
public getDaysToConversion ( integer $idSite, string $period, string $date, string | boolean $segment = false, integer | boolean $idGoal = false ) : false | DataTable
$idSite integer The site to select data from.
$period string The period type.
$date string The date type.
$segment string | boolean The segment.
$idGoal integer | boolean The id of the goal to get data for. If this is set to false, data for every goal that belongs to $idSite is returned.
Результат false | Piwik\DataTable

getGoal() публичный Метод

Return a single goal.
public getGoal ( integer $idSite, integer $idGoal ) : array
$idSite integer
$idGoal integer
Результат array An array of goal attributes.

getGoalSpecificDataTable() защищенный Метод

Utility method that retrieve an archived DataTable for a specific site, date range, segment and goal. If not goal is specified, this method will retrieve and sum the data for every goal.
protected getGoalSpecificDataTable ( string $recordName, integer | string $idSite, string $period, string $date, string $segment, integer | boolean $idGoal ) : false | DataTable
$recordName string The archive entry name.
$idSite integer | string The site(s) to select data for.
$period string The period type.
$date string The date type.
$segment string The segment.
$idGoal integer | boolean The id of the goal to get data for. If this is set to false, data for every goal that belongs to $idSite is returned.
Результат false | Piwik\DataTable

getGoals() публичный Метод

Returns all Goals for a given website, or list of websites
public getGoals ( string | array $idSite ) : array
$idSite string | array Array or Comma separated list of website IDs to request the goals for
Результат array Array of Goal attributes

getItems() защищенный Метод

Returns a datatable of Items SKU/name or categories and their metrics If $abandonedCarts set to 1, will return items abandoned in carts. If set to 0, will return items ordered
protected getItems ( $recordName, $idSite, $period, $date, $abandonedCarts, $segment )

getItemsCategory() публичный Метод

public getItemsCategory ( $idSite, $period, $date, $abandonedCarts = false, $segment = false )

getItemsName() публичный Метод

public getItemsName ( $idSite, $period, $date, $abandonedCarts = false, $segment = false )

getItemsSku() публичный Метод

public getItemsSku ( $idSite, $period, $date, $abandonedCarts = false, $segment = false )

getMetrics() публичный Метод

Similar to {@link get()} but does not return any metrics for new and returning visitors. It won't apply any segment by default. This method is deprecated from the API as it is only there to make the implementation of the actual {@link get()} method easy.
Устаревший:
public getMetrics ( $idSite, $period, $date, $segment = false, $idGoal = false, $columns = [] )

getNbVisitsConverted() публичный Метод

public getNbVisitsConverted ( $idSite, $period, $date, $segment = false, $idGoal = false )

getNumeric() защищенный Метод

protected getNumeric ( $idSite, $period, $date, $segment, $toFetch )

getRevenue() публичный Метод

public getRevenue ( $idSite, $period, $date, $segment = false, $idGoal = false )

getVisitsUntilConversion() публичный Метод

Gets a DataTable that maps ranges of visit counts to the number of conversions that occurred on those visits for the specified site, date range, segment and goal.
public getVisitsUntilConversion ( integer $idSite, string $period, string $date, string | boolean $segment = false, integer | boolean $idGoal = false ) : boolean | DataTable
$idSite integer The site to select data from.
$period string The period type.
$date string The date type.
$segment string | boolean The segment.
$idGoal integer | boolean The id of the goal to get data for. If this is set to false, data for every goal that belongs to $idSite is returned.
Результат boolean | Piwik\DataTable

renameNotDefinedRow() защищенный Метод

protected renameNotDefinedRow ( $dataTable, $notDefinedStringPretty )

updateGoal() публичный Метод

Will not update or re-process the conversions already recorded
См. также: addGoal() for parameters description
public updateGoal ( integer $idSite, integer $idGoal, $name, $matchAttribute, string $pattern, string $patternType, boolean $caseSensitive = false, boolean | float $revenue = false, boolean $allowMultipleConversionsPerVisit = false, string $description = '' ) : void
$idSite integer
$idGoal integer
$name
$matchAttribute
$pattern string
$patternType string
$caseSensitive boolean
$revenue boolean | float
$allowMultipleConversionsPerVisit boolean
$description string
Результат void