PHP Класс PiwikTracker, piwik-php-tracker

Наследование: extends Tracker
Показать файл Открыть проект Примеры использования класса

Открытые свойства

Свойство Тип Описание
$DEBUG_APPEND_URL
$DEBUG_LAST_REQUESTED_URL Used in tests to output useful error messages.
$URL string Piwik base URL, for example http://example.org/piwik/ Must be set before using the class by calling PiwikTracker::$URL = 'http://yourwebsite.org/piwik/';

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

Метод Описание
__construct ( integer $idSite, string $apiUrl = '' ) Builds a PiwikTracker object, used to track visits, pages and Goal conversions for a specific website, by using the Piwik Tracking API.
addEcommerceItem ( string $sku, string $name = '', string | array $category = '', float | integer $price, integer $quantity = 1 ) Adds an item in the Ecommerce order.
clearCustomTrackingParameters ( ) Clear / reset all previously set custom tracking parameters.
clearCustomVariables ( ) Clears any Custom Variable that may be have been set.
deleteCookies ( ) Deletes all first party cookies from the client
disableCookieSupport ( ) By default, PiwikTracker will read first party cookies from the request and write updated cookies in the response (using setrawcookie).
disableSendImageResponse ( ) If image response is disabled Piwik will respond with a HTTP 204 header instead of responding with a gif.
doBulkTrack ( ) : string Sends all stored tracking actions at once. Only has an effect if bulk tracking is enabled.
doPing ( ) : mixed Sends a ping request.
doTrackAction ( string $actionUrl, string $actionType ) : mixed Tracks a download or outlink
doTrackContentImpression ( string $contentName, string $contentPiece = 'Unknown', string | boolean $contentTarget = false ) : mixed Tracks a content impression
doTrackContentInteraction ( string $interaction, string $contentName, string $contentPiece = 'Unknown', string | boolean $contentTarget = false ) : mixed Tracks a content interaction. Make sure you have tracked a content impression using the same content name and content piece, otherwise it will not count. To do so you should call the method doTrackContentImpression();
doTrackEcommerceCartUpdate ( float $grandTotal ) : mixed Tracks a Cart Update (add item, remove item, update item).
doTrackEcommerceOrder ( string | integer $orderId, float $grandTotal, float $subTotal, float $tax, float $shipping, float $discount ) : mixed Tracks an Ecommerce order.
doTrackEvent ( string $category, string $action, string | boolean $name = false, float | boolean $value = false ) : mixed Tracks an event
doTrackGoal ( integer $idGoal, float $revenue ) : mixed Records a Goal conversion
doTrackPageView ( string $documentTitle ) : mixed Tracks a page view
doTrackSiteSearch ( string $keyword, string $category = '', boolean | integer $countResults = false ) : mixed Tracks an internal Site Search query, and optionally tracks the Search Category, and Search results Count.
enableBulkTracking ( ) Enables the bulk request feature. When used, each tracking action is stored until the doBulkTrack method is called. This method will send all tracking data at once.
enableCookies ( string $domain = '', string $path = '/' ) Enable Cookie Creation - this will cause a first party VisitorId cookie to be set when the VisitorId is set or reset
getAttributionInfo ( ) : string Returns the currently assigned Attribution Information stored in a first party cookie.
getCustomVariable ( integer $id, string $scope = 'visit' ) : mixed Returns the currently assigned Custom Variable.
getRequestTimeout ( ) Returns the maximum number of seconds the tracker will spend waiting for a response from Piwik. Defaults to 600 seconds.
getUrlTrackAction ( string $actionUrl, string $actionType ) : string Builds URL to track a new action.
getUrlTrackContentImpression ( string $contentName, string $contentPiece, string | false $contentTarget ) : string Builds URL to track a content impression.
getUrlTrackContentInteraction ( string $interaction, string $contentName, string $contentPiece, string | false $contentTarget ) : string Builds URL to track a content impression.
getUrlTrackEcommerceCartUpdate ( $grandTotal ) Returns URL used to track Ecommerce Cart updates Calling this function will reinitializes the property ecommerceItems to empty array so items will have to be added again via addEcommerceItem()
getUrlTrackEcommerceOrder ( $orderId, $grandTotal, $subTotal, $tax, $shipping, $discount ) Returns URL used to track Ecommerce Orders Calling this function will reinitializes the property ecommerceItems to empty array so items will have to be added again via addEcommerceItem()
getUrlTrackEvent ( string $category, string $action, string | boolean $name = false, float | boolean $value = false ) : string Builds URL to track a custom event.
getUrlTrackGoal ( integer $idGoal, float $revenue ) : string Builds URL to track a goal with idGoal and revenue.
getUrlTrackPageView ( string $documentTitle = '' ) : string Builds URL to track a page view.
getUrlTrackSiteSearch ( string $keyword, string $category, integer $countResults ) : string Builds URL to track a site search.
getUserId ( ) : boolean Returns the User ID string, which may have been set via: $v->setUserId('[email protected]');
getUserIdHashed ( $id ) : string Hash function used internally by Piwik to hash a User ID into the Visitor ID.
getVisitorId ( ) : string If the user initiating the request has the Piwik first party cookie, this function will try and return the ID parsed from this first party cookie (found in $_COOKIE).
setAttributionInfo ( string $jsonEncoded ) Sets the attribution information to the visit, so that subsequent Goal conversions are properly attributed to the right Referrer URL, timestamp, Campaign Name & Keyword.
setBrowserHasCookies ( boolean $bool ) Sets if the browser supports cookies This is reported in "List of plugins" report in Piwik.
setBrowserLanguage ( string $acceptLanguage ) Sets the Browser language. Used to guess visitor countries when GeoIP is not enabled
setCity ( string $city ) Sets the city of the visitor. If not used, Piwik may try to find the city using the visitor's IP address (if configured to do so).
setCountry ( string $country ) Sets the country of the visitor. If not used, Piwik will try to find the country using either the visitor's IP address or language.
setCustomTrackingParameter ( string $trackingApiParameter, string $value ) Sets a custom tracking parameter. This is useful if you need to send any tracking parameters for a 3rd party plugin that is not shipped with Piwik itself. Please note that custom parameters are cleared after each tracking request.
setCustomVariable ( integer $id, string $name, string $value, string $scope = 'visit' ) Sets Visit Custom Variable.
setDebugStringAppend ( string $string ) Will append a custom string at the end of the Tracking request.
setEcommerceView ( string $sku = '', string $name = '', string | array $category = '', float $price ) Sets the current page view as an item (product) page view, or an Ecommerce Category page view.
setForceNewVisit ( ) Forces Piwik to create a new visit for the tracking request.
setForceVisitDateTime ( string $dateTime ) Overrides server date and time for the tracking requests.
setGenerationTime ( integer $timeMs ) Sets the time that generating the document on the server side took.
setIdSite ( integer $idSite ) Sets the current site ID.
setIp ( string $ip ) Overrides IP address
setLatitude ( float $lat ) Sets the latitude of the visitor. If not used, Piwik may try to find the visitor's latitude using the visitor's IP address (if configured to do so).
setLocalTime ( string $time ) Sets local visitor time
setLongitude ( float $long ) Sets the longitude of the visitor. If not used, Piwik may try to find the visitor's longitude using the visitor's IP address (if configured to do so).
setNewVisitorId ( ) Sets the current visitor ID to a random new one.
setPageCharset ( string $charset = '' ) By default, Piwik expects utf-8 encoded values, for example for the page URL parameter values, Page Title, etc.
setPlugins ( boolean $flash = false, boolean $java = false, boolean $director = false, boolean $quickTime = false, boolean $realPlayer = false, boolean $pdf = false, boolean $windowsMedia = false, boolean $gears = false, boolean $silverlight = false ) Sets visitor browser supported plugins
setProxy ( string $proxy, integer $proxyPort = 80 ) If a proxy is needed to look up the address of the Piwik site, set it with this
setRegion ( string $region ) Sets the region of the visitor. If not used, Piwik may try to find the region using the visitor's IP address (if configured to do so).
setRequestTimeout ( integer $timeout ) Sets the maximum number of seconds that the tracker will spend waiting for a response from Piwik.
setResolution ( integer $width, integer $height ) Sets user resolution width and height.
setTokenAuth ( string $token_auth ) Some Tracking API functionality requires express authentication, using either the Super User token_auth, or a user with 'admin' access to the website.
setUrl ( string $url ) Sets the current URL being tracked
setUrlReferer ( $url )
setUrlReferrer ( string $url ) Sets the URL referrer used to track Referrers details for new visits.
setUserAgent ( string $userAgent ) Sets the user agent, used to detect OS and browser.
setUserId ( string $userId ) Force the action to be recorded for a specific User. The User ID is a string representing a given user in your system.
setVisitorId ( string $visitorId ) Forces the requests to be recorded for the specified Visitor ID.

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

Метод Описание
domainFixup ( $domain ) Fix-up domain
getBaseUrl ( ) Returns the base URL for the piwik server.
getCookieMatchingName ( string $name ) : string Returns a first party cookie which name contains $name
getCookieName ( string $cookieName ) : string Get cookie name with prefix and domain hash
getCurrentHost ( ) : string If current URL is "http://example.org/dir1/dir2/index.php?param1=value1¶m2=value2" will return "http://example.org"
getCurrentQueryString ( ) : string If current URL is "http://example.org/dir1/dir2/index.php?param1=value1¶m2=value2" will return "?param1=value1¶m2=value2"
getCurrentScheme ( ) : string If the current URL is 'http://example.org/dir1/dir2/index.php?param1=value1¶m2=value2" will return 'http'
getCurrentScriptName ( ) : string If current URL is "http://example.org/dir1/dir2/index.php?param1=value1¶m2=value2" will return "/dir1/dir2/index.php"
getCurrentUrl ( ) : string Returns the current full URL (scheme, host, path and query string.
getCustomVariablesFromCookie ( ) : boolean | mixed
getRequest ( $idSite )
getTimestamp ( ) : string | integer Returns current timestamp, or forced timestamp/datetime if it was set
getUrlTrackEcommerce ( $grandTotal, $subTotal, $tax, $shipping, $discount ) Returns URL used to track Ecommerce orders
loadVisitorIdCookie ( ) : boolean Loads values from the VisitorId Cookie
sendRequest ( $url, $method = 'GET', $data = null, $force = false )
setCookie ( $cookieName, $cookieValue, $cookieTTL ) Sets a first party cookie to the client to improve dual JS-PHP tracking.
setFirstPartyCookies ( ) Sets the first party cookies as would the piwik.js All cookies are supported: 'id' and 'ses' and 'ref' and 'cvar' cookies.

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

Метод Описание
forceDotAsSeparatorForDecimalPoint ( float | string $value ) : string Force the separator for decimal point to be a dot. See https://github.com/piwik/piwik/issues/6435 If for instance a German locale is used it would be a comma otherwise.
getProxy ( ) If the proxy IP and the proxy port have been set, with the setProxy() function returns a string, like "173.234.92.107:80"

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

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

Builds a PiwikTracker object, used to track visits, pages and Goal conversions for a specific website, by using the Piwik Tracking API.
public __construct ( integer $idSite, string $apiUrl = '' )
$idSite integer Id site to be tracked
$apiUrl string "http://example.org/piwik/" or "http://piwik.example.org/" If set, will overwrite PiwikTracker::$URL

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

This should be called before doTrackEcommerceOrder(), or before doTrackEcommerceCartUpdate(). This function can be called for all individual products in the cart (or order). SKU parameter is mandatory. Other parameters are optional (set to false if value not known). Ecommerce items added via this function are automatically cleared when doTrackEcommerceOrder() or getUrlTrackEcommerceOrder() is called.
public addEcommerceItem ( string $sku, string $name = '', string | array $category = '', float | integer $price, integer $quantity = 1 )
$sku string (required) SKU, Product identifier
$name string (optional) Product name
$category string | array (optional) Product category, or array of product categories (up to 5 categories can be specified for a given product)
$price float | integer (optional) Individual product price (supports integer and decimal prices)
$quantity integer (optional) Product quantity. If not specified, will default to 1 in the Reports

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

Clear / reset all previously set custom tracking parameters.

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

This can be useful when you have enabled bulk requests, and you wish to clear Custom Variables of 'visit' scope.

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

Deletes all first party cookies from the client
public deleteCookies ( )

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

This can be disabled by calling this function.

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

If image response is disabled Piwik will respond with a HTTP 204 header instead of responding with a gif.

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

To enable bulk tracking, call enableBulkTracking().
public doBulkTrack ( ) : string
Результат string Response

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

Ping requests do not track new actions. If they are sent within the standard visit length (see global.ini.php), they will extend the existing visit and the current last action for the visit. If after the standard visit length, ping requests will create a new visit using the last action in the last known visit.
public doPing ( ) : mixed
Результат mixed Response or true if using bulk request

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

Tracks a download or outlink
public doTrackAction ( string $actionUrl, string $actionType ) : mixed
$actionUrl string URL of the download or outlink
$actionType string Type of the action: 'download' or 'link'
Результат mixed Response or true if using bulk request

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

Tracks a content impression
public doTrackContentImpression ( string $contentName, string $contentPiece = 'Unknown', string | boolean $contentTarget = false ) : mixed
$contentName string The name of the content. For instance 'Ad Foo Bar'
$contentPiece string The actual content. For instance the path to an image, video, audio, any text
$contentTarget string | boolean (optional) The target of the content. For instance the URL of a landing page.
Результат mixed Response string or true if using bulk requests.

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

Tracks a content interaction. Make sure you have tracked a content impression using the same content name and content piece, otherwise it will not count. To do so you should call the method doTrackContentImpression();
public doTrackContentInteraction ( string $interaction, string $contentName, string $contentPiece = 'Unknown', string | boolean $contentTarget = false ) : mixed
$interaction string The name of the interaction with the content. For instance a 'click'
$contentName string The name of the content. For instance 'Ad Foo Bar'
$contentPiece string The actual content. For instance the path to an image, video, audio, any text
$contentTarget string | boolean (optional) The target the content leading to when an interaction occurs. For instance the URL of a landing page.
Результат mixed Response string or true if using bulk requests.

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

On every Cart update, you must call addEcommerceItem() for each item (product) in the cart, including the items that haven't been updated since the last cart update. Items which were in the previous cart and are not sent in later Cart updates will be deleted from the cart (in the database).
public doTrackEcommerceCartUpdate ( float $grandTotal ) : mixed
$grandTotal float Cart grandTotal (typically the sum of all items' prices)
Результат mixed Response or true if using bulk request

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

If the Ecommerce order contains items (products), you must call first the addEcommerceItem() for each item in the order. All revenues (grandTotal, subTotal, tax, shipping, discount) will be individually summed and reported in Piwik reports. Only the parameters $orderId and $grandTotal are required.
public doTrackEcommerceOrder ( string | integer $orderId, float $grandTotal, float $subTotal, float $tax, float $shipping, float $discount ) : mixed
$orderId string | integer (required) Unique Order ID. This will be used to count this order only once in the event the order page is reloaded several times. orderId must be unique for each transaction, even on different days, or the transaction will not be recorded by Piwik.
$grandTotal float (required) Grand Total revenue of the transaction (including tax, shipping, etc.)
$subTotal float (optional) Sub total amount, typically the sum of items prices for all items in this order (before Tax and Shipping costs are applied)
$tax float (optional) Tax amount for this order
$shipping float (optional) Shipping amount for this order
$discount float (optional) Discounted amount in this order
Результат mixed Response or true if using bulk request

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

Tracks an event
public doTrackEvent ( string $category, string $action, string | boolean $name = false, float | boolean $value = false ) : mixed
$category string The Event Category (Videos, Music, Games...)
$action string The Event's Action (Play, Pause, Duration, Add Playlist, Downloaded, Clicked...)
$name string | boolean (optional) The Event's object Name (a particular Movie name, or Song name, or File name...)
$value float | boolean (optional) The Event's value
Результат mixed Response string or true if using bulk requests.

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

Records a Goal conversion
public doTrackGoal ( integer $idGoal, float $revenue ) : mixed
$idGoal integer Id Goal to record a conversion
$revenue float Revenue for this conversion
Результат mixed Response or true if using bulk request

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

Tracks a page view
public doTrackPageView ( string $documentTitle ) : mixed
$documentTitle string Page title as it will appear in the Actions > Page titles report
Результат mixed Response string or true if using bulk requests.

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

These are used to populate reports in Actions > Site Search.
public doTrackSiteSearch ( string $keyword, string $category = '', boolean | integer $countResults = false ) : mixed
$keyword string Searched query on the site
$category string (optional) Search engine category if applicable
$countResults boolean | integer (optional) results displayed on the search result page. Used to track "zero result" keywords.
Результат mixed Response or true if using bulk requests.

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

Fix-up domain
protected static domainFixup ( $domain )

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

Enables the bulk request feature. When used, each tracking action is stored until the doBulkTrack method is called. This method will send all tracking data at once.
public enableBulkTracking ( )

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

Enable Cookie Creation - this will cause a first party VisitorId cookie to be set when the VisitorId is set or reset
public enableCookies ( string $domain = '', string $path = '/' )
$domain string (optional) Set first-party cookie domain. Accepted values: example.com, *.example.com (same as .example.com) or subdomain.example.com
$path string (optional) Set first-party cookie path

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

This function will only work if the user is initiating the current request, and his cookies can be read by PHP from the $_COOKIE array.
public getAttributionInfo ( ) : string
Результат string JSON Encoded string containing the Referrer information for Goal conversion attribution. Will return false if the cookie could not be found

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

Returns the base URL for the piwik server.
protected getBaseUrl ( )

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

Returns a first party cookie which name contains $name
protected getCookieMatchingName ( string $name ) : string
$name string
Результат string String value of cookie, or false if not found

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

Get cookie name with prefix and domain hash
protected getCookieName ( string $cookieName ) : string
$cookieName string
Результат string

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

If current URL is "http://example.org/dir1/dir2/index.php?param1=value1¶m2=value2" will return "http://example.org"
protected static getCurrentHost ( ) : string
Результат string

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

If current URL is "http://example.org/dir1/dir2/index.php?param1=value1¶m2=value2" will return "?param1=value1¶m2=value2"
protected static getCurrentQueryString ( ) : string
Результат string

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

If the current URL is 'http://example.org/dir1/dir2/index.php?param1=value1¶m2=value2" will return 'http'
protected static getCurrentScheme ( ) : string
Результат string 'https' or 'http'

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

If current URL is "http://example.org/dir1/dir2/index.php?param1=value1¶m2=value2" will return "/dir1/dir2/index.php"
protected static getCurrentScriptName ( ) : string
Результат string

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

Returns the current full URL (scheme, host, path and query string.
protected static getCurrentUrl ( ) : string
Результат string

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

If scope is 'visit', it will attempt to read the value set in the first party cookie created by Piwik Tracker ($_COOKIE array).
public getCustomVariable ( integer $id, string $scope = 'visit' ) : mixed
$id integer Custom Variable integer index to fetch from cookie. Should be a value from 1 to 5
$scope string Custom variable scope. Possible values: visit, page, event
Результат mixed An array with this format: array( 0 => CustomVariableName, 1 => CustomVariableValue ) or false

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

protected getCustomVariablesFromCookie ( ) : boolean | mixed
Результат boolean | mixed

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

protected getRequest ( $idSite )

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

Returns the maximum number of seconds the tracker will spend waiting for a response from Piwik. Defaults to 600 seconds.
public getRequestTimeout ( )

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

Returns current timestamp, or forced timestamp/datetime if it was set
protected getTimestamp ( ) : string | integer
Результат string | integer

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

Builds URL to track a new action.
См. также: doTrackAction()
public getUrlTrackAction ( string $actionUrl, string $actionType ) : string
$actionUrl string URL of the download or outlink
$actionType string Type of the action: 'download' or 'link'
Результат string URL to piwik.php with all parameters set to track an action

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

Builds URL to track a content impression.
См. также: doTrackContentImpression()
public getUrlTrackContentImpression ( string $contentName, string $contentPiece, string | false $contentTarget ) : string
$contentName string The name of the content. For instance 'Ad Foo Bar'
$contentPiece string The actual content. For instance the path to an image, video, audio, any text
$contentTarget string | false (optional) The target of the content. For instance the URL of a landing page.
Результат string URL to piwik.php with all parameters set to track the pageview

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

Builds URL to track a content impression.
См. также: doTrackContentInteraction()
public getUrlTrackContentInteraction ( string $interaction, string $contentName, string $contentPiece, string | false $contentTarget ) : string
$interaction string The name of the interaction with the content. For instance a 'click'
$contentName string The name of the content. For instance 'Ad Foo Bar'
$contentPiece string The actual content. For instance the path to an image, video, audio, any text
$contentTarget string | false (optional) The target the content leading to when an interaction occurs. For instance the URL of a landing page.
Результат string URL to piwik.php with all parameters set to track the pageview

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

Calling this function will reinitializes the property ecommerceItems to empty array so items will have to be added again via addEcommerceItem()
protected getUrlTrackEcommerce ( $grandTotal, $subTotal, $tax, $shipping, $discount )

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

Returns URL used to track Ecommerce Cart updates Calling this function will reinitializes the property ecommerceItems to empty array so items will have to be added again via addEcommerceItem()
public getUrlTrackEcommerceCartUpdate ( $grandTotal )

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

Returns URL used to track Ecommerce Orders Calling this function will reinitializes the property ecommerceItems to empty array so items will have to be added again via addEcommerceItem()
public getUrlTrackEcommerceOrder ( $orderId, $grandTotal, $subTotal, $tax, $shipping, $discount )

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

Builds URL to track a custom event.
См. также: doTrackEvent()
public getUrlTrackEvent ( string $category, string $action, string | boolean $name = false, float | boolean $value = false ) : string
$category string The Event Category (Videos, Music, Games...)
$action string The Event's Action (Play, Pause, Duration, Add Playlist, Downloaded, Clicked...)
$name string | boolean (optional) The Event's object Name (a particular Movie name, or Song name, or File name...)
$value float | boolean (optional) The Event's value
Результат string URL to piwik.php with all parameters set to track the pageview

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

Builds URL to track a goal with idGoal and revenue.
См. также: doTrackGoal()
public getUrlTrackGoal ( integer $idGoal, float $revenue ) : string
$idGoal integer Id Goal to record a conversion
$revenue float Revenue for this conversion
Результат string URL to piwik.php with all parameters set to track the goal conversion

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

Builds URL to track a page view.
См. также: doTrackPageView()
public getUrlTrackPageView ( string $documentTitle = '' ) : string
$documentTitle string Page view name as it will appear in Piwik reports
Результат string URL to piwik.php with all parameters set to track the pageview

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

Builds URL to track a site search.
См. также: doTrackSiteSearch()
public getUrlTrackSiteSearch ( string $keyword, string $category, integer $countResults ) : string
$keyword string
$category string
$countResults integer
Результат string

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

Returns the User ID string, which may have been set via: $v->setUserId('[email protected]');
public getUserId ( ) : boolean
Результат boolean

getUserIdHashed() публичный статический Метод

Note: matches implementation of Tracker\Request->getUserIdHashed()
public static getUserIdHashed ( $id ) : string
$id
Результат string

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

If you call this function from a server, where the call is triggered by a cron or script not initiated by the actual visitor being tracked, then it will return the random Visitor ID that was assigned to this visit object. This can be used if you wish to record more visits, actions or goals for this visitor ID later on.
public getVisitorId ( ) : string
Результат string 16 hex chars visitor ID string

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

Loads values from the VisitorId Cookie
protected loadVisitorIdCookie ( ) : boolean
Результат boolean True if cookie exists and is valid, False otherwise

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

protected sendRequest ( $url, $method = 'GET', $data = null, $force = false )

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

This must be a JSON encoded string that would typically be fetched from the JS API: piwikTracker.getAttributionInfo() and that you have JSON encoded via JSON2.stringify() If you call enableCookies() then these referral attribution values will be set to the 'ref' first party cookie storing referral information.
См. также: function getAttributionInfo() in https://github.com/piwik/piwik/blob/master/js/piwik.js
public setAttributionInfo ( string $jsonEncoded )
$jsonEncoded string JSON encoded array containing Attribution info

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

Sets if the browser supports cookies This is reported in "List of plugins" report in Piwik.
public setBrowserHasCookies ( boolean $bool )
$bool boolean

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

Sets the Browser language. Used to guess visitor countries when GeoIP is not enabled
public setBrowserLanguage ( string $acceptLanguage )
$acceptLanguage string For example "fr-fr"

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

Allowed only for Admin/Super User, must be used along with setTokenAuth().
public setCity ( string $city )
$city string

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

This replicates the piwik.js tracker algorithms for consistency and better accuracy.
protected setCookie ( $cookieName, $cookieValue, $cookieTTL )
$cookieName
$cookieValue
$cookieTTL

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

Allowed only for Admin/Super User, must be used along with setTokenAuth().
public setCountry ( string $country )
$country string

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

Sets a custom tracking parameter. This is useful if you need to send any tracking parameters for a 3rd party plugin that is not shipped with Piwik itself. Please note that custom parameters are cleared after each tracking request.
public setCustomTrackingParameter ( string $trackingApiParameter, string $value )
$trackingApiParameter string The name of the tracking API parameter, eg 'dimension1'
$value string Tracking parameter value that shall be sent for this tracking parameter.

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

See http://piwik.org/docs/custom-variables/
public setCustomVariable ( integer $id, string $name, string $value, string $scope = 'visit' )
$id integer Custom variable slot ID from 1-5
$name string Custom variable name
$value string Custom variable value
$scope string Custom variable scope. Possible values: visit, page, event

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

Will append a custom string at the end of the Tracking request.
public setDebugStringAppend ( string $string )
$string string

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

This must be called before doTrackPageView() on this product/category page. It will set 3 custom variables of scope "page" with the SKU, Name and Category for this page view. Note: Custom Variables of scope "page" slots 3, 4 and 5 will be used. On a category page, you may set the parameter $category only and set the other parameters to false. Tracking Product/Category page views will allow Piwik to report on Product & Categories conversion rates (Conversion rate = Ecommerce orders containing this product or category / Visits to the product or category)
public setEcommerceView ( string $sku = '', string $name = '', string | array $category = '', float $price )
$sku string Product SKU being viewed
$name string Product Name being viewed
$category string | array Category being viewed. On a Product page, this is the product's category. You can also specify an array of up to 5 categories for a given page view.
$price float Specify the price at which the item was displayed

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

Sets the first party cookies as would the piwik.js All cookies are supported: 'id' and 'ses' and 'ref' and 'cvar' cookies.
protected setFirstPartyCookies ( )

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

By default, Piwik will create a new visit if the last request by this user was more than 30 minutes ago. If you call setForceNewVisit() before calling doTrack*, then a new visit will be created for this request.
public setForceNewVisit ( )

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

By default Piwik will track requests for the "current datetime" but this function allows you to track visits in the past. All times are in UTC. Allowed only for Super User, must be used along with setTokenAuth()
См. также: setTokenAuth()
public setForceVisitDateTime ( string $dateTime )
$dateTime string Date with the format 'Y-m-d H:i:s', or a UNIX timestamp

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

Sets the time that generating the document on the server side took.
public setGenerationTime ( integer $timeMs )
$timeMs integer Generation time in ms

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

Sets the current site ID.
public setIdSite ( integer $idSite )
$idSite integer

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

Allowed only for Super User, must be used along with setTokenAuth()
См. также: setTokenAuth()
public setIp ( string $ip )
$ip string IP string, eg. 130.54.2.1

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

Allowed only for Admin/Super User, must be used along with setTokenAuth().
public setLatitude ( float $lat )
$lat float

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

Sets local visitor time
public setLocalTime ( string $time )
$time string HH:MM:SS format

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

Allowed only for Admin/Super User, must be used along with setTokenAuth().
public setLongitude ( float $long )
$long float

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

Sets the current visitor ID to a random new one.
public setNewVisitorId ( )

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

It is recommended to only send UTF-8 data to Piwik. If required though, you can also specify another charset using this function.
public setPageCharset ( string $charset = '' )
$charset string

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

Sets visitor browser supported plugins
public setPlugins ( boolean $flash = false, boolean $java = false, boolean $director = false, boolean $quickTime = false, boolean $realPlayer = false, boolean $pdf = false, boolean $windowsMedia = false, boolean $gears = false, boolean $silverlight = false )
$flash boolean
$java boolean
$director boolean
$quickTime boolean
$realPlayer boolean
$pdf boolean
$windowsMedia boolean
$gears boolean
$silverlight boolean

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

If a proxy is needed to look up the address of the Piwik site, set it with this
public setProxy ( string $proxy, integer $proxyPort = 80 )
$proxy string IP as string, for example "173.234.92.107"
$proxyPort integer

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

Allowed only for Admin/Super User, must be used along with setTokenAuth().
public setRegion ( string $region )
$region string

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

Sets the maximum number of seconds that the tracker will spend waiting for a response from Piwik.
public setRequestTimeout ( integer $timeout )
$timeout integer

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

Sets user resolution width and height.
public setResolution ( integer $width, integer $height )
$width integer
$height integer

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

The following features require access: - force the visitor IP - force the date & time of the tracking requests rather than track for the current datetime
public setTokenAuth ( string $token_auth )
$token_auth string token_auth 32 chars token_auth string

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

Sets the current URL being tracked
public setUrl ( string $url )
$url string Raw URL (not URL encoded)

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

Устаревший:
public setUrlReferer ( $url )

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

Sets the URL referrer used to track Referrers details for new visits.
public setUrlReferrer ( string $url )
$url string Raw URL (not URL encoded)

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

If this function is not called, the User Agent will default to the current user agent.
public setUserAgent ( string $userAgent )
$userAgent string

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

A User ID can be a username, UUID or an email address, or any number or string that uniquely identifies a user or client.
public setUserId ( string $userId )
$userId string Any user ID string (eg. email address, ID, username). Must be non empty. Set to false to de-assign a user id previously set.

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

Note: it is recommended to use ->setUserId($userId); instead. Rather than letting Piwik attribute the user with a heuristic based on IP and other user fingeprinting attributes, force the action to be recorded for a particular visitor. If you use both setVisitorId and setUserId, setUserId will take precedence. If not set, the visitor ID will be fetched from the 1st party cookie, or will be set to a random UUID.
Устаревший: We recommend to use ->setUserId($userId).
public setVisitorId ( string $visitorId )
$visitorId string 16 hexadecimal characters visitor ID, eg. "33c31e01394bdc63"

Описание свойств

$DEBUG_APPEND_URL публичное свойство

public $DEBUG_APPEND_URL

$DEBUG_LAST_REQUESTED_URL публичное статическое свойство

Used in tests to output useful error messages.
public static $DEBUG_LAST_REQUESTED_URL

$URL публичное статическое свойство

Piwik base URL, for example http://example.org/piwik/ Must be set before using the class by calling PiwikTracker::$URL = 'http://yourwebsite.org/piwik/';
public static string $URL
Результат string