Свойство | Тип | Описание | |
---|---|---|---|
$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" |
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 |
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 |
public clearCustomTrackingParameters ( ) |
public clearCustomVariables ( ) |
public deleteCookies ( ) |
public disableCookieSupport ( ) |
public disableSendImageResponse ( ) |
public doBulkTrack ( ) : string | ||
Результат | string | Response |
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. |
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. |
public doTrackEcommerceCartUpdate ( float $grandTotal ) : mixed | ||
$grandTotal | float | Cart grandTotal (typically the sum of all items' prices) |
Результат | mixed | Response or true if using bulk request |
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 |
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. |
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. |
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. |
public enableBulkTracking ( ) |
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 |
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 |
protected getCookieMatchingName ( string $name ) : string | ||
$name | string | |
Результат | string | String value of cookie, or false if not found |
protected getCookieName ( string $cookieName ) : string | ||
$cookieName | string | |
Результат | string |
protected static getCurrentHost ( ) : string | ||
Результат | string |
protected static getCurrentQueryString ( ) : string | ||
Результат | string |
protected static getCurrentScheme ( ) : string | ||
Результат | string | 'https' or 'http' |
protected static getCurrentScriptName ( ) : string | ||
Результат | string |
protected static getCurrentUrl ( ) : string | ||
Результат | string |
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 |
protected getCustomVariablesFromCookie ( ) : boolean | mixed | ||
Результат | boolean | mixed |
public getRequestTimeout ( ) |
protected getTimestamp ( ) : string | integer | ||
Результат | string | integer |
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 |
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 |
protected getUrlTrackEcommerce ( $grandTotal, $subTotal, $tax, $shipping, $discount ) |
public getUrlTrackEcommerceCartUpdate ( $grandTotal ) |
public getUrlTrackEcommerceOrder ( $orderId, $grandTotal, $subTotal, $tax, $shipping, $discount ) |
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 |
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 |
public static getUserIdHashed ( $id ) : string | ||
$id | ||
Результат | string |
public getVisitorId ( ) : string | ||
Результат | string | 16 hex chars visitor ID string |
protected loadVisitorIdCookie ( ) : boolean | ||
Результат | boolean | True if cookie exists and is valid, False otherwise |
protected sendRequest ( $url, $method = 'GET', $data = null, $force = false ) |
public setAttributionInfo ( string $jsonEncoded ) | ||
$jsonEncoded | string | JSON encoded array containing Attribution info |
public setBrowserHasCookies ( boolean $bool ) | ||
$bool | boolean |
public setBrowserLanguage ( string $acceptLanguage ) | ||
$acceptLanguage | string | For example "fr-fr" |
protected setCookie ( $cookieName, $cookieValue, $cookieTTL ) | ||
$cookieName | ||
$cookieValue | ||
$cookieTTL |
public setCountry ( string $country ) | ||
$country | string |
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. |
public setDebugStringAppend ( string $string ) | ||
$string | string |
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 |
protected setFirstPartyCookies ( ) |
public setForceNewVisit ( ) |
public setForceVisitDateTime ( string $dateTime ) | ||
$dateTime | string | Date with the format 'Y-m-d H:i:s', or a UNIX timestamp |
public setGenerationTime ( integer $timeMs ) | ||
$timeMs | integer | Generation time in ms |
public setLatitude ( float $lat ) | ||
$lat | float |
public setLocalTime ( string $time ) | ||
$time | string | HH:MM:SS format |
public setLongitude ( float $long ) | ||
$long | float |
public setNewVisitorId ( ) |
public setPageCharset ( string $charset = '' ) | ||
$charset | string |
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 | |
boolean | ||
$windowsMedia | boolean | |
$gears | boolean | |
$silverlight | boolean |
public setRequestTimeout ( integer $timeout ) | ||
$timeout | integer |
public setResolution ( integer $width, integer $height ) | ||
$width | integer | |
$height | integer |
public setTokenAuth ( string $token_auth ) | ||
$token_auth | string | token_auth 32 chars token_auth string |
public setUrlReferrer ( string $url ) | ||
$url | string | Raw URL (not URL encoded) |
public setUserAgent ( string $userAgent ) | ||
$userAgent | string |
public setVisitorId ( string $visitorId ) | ||
$visitorId | string | 16 hexadecimal characters visitor ID, eg. "33c31e01394bdc63" |
public static $DEBUG_LAST_REQUESTED_URL |
public static string $URL | ||
Результат | string |