C# (CSharp) Piwik.Tracker Namespace

Nested Namespaces

Piwik.Tracker.Samples

Classes

Name Description
PiwikTracker PiwikTracker implements the Piwik Tracking Web API. The PHP Tracking Client provides all features of the Javascript Tracker, such as Ecommerce Tracking, Custom Variable, Event tracking and more. Functions are named the same as the Javascript functions. See introduction docs at: {@link http://piwik.org/docs/tracking-api/} ### Example: using the PHP PiwikTracker class The following code snippet is an advanced example of how to track a Page View using the Tracking API PHP client. $t = new PiwikTracker( $idSite = 1, 'http://example.org/piwik/'); // Optional function calls $t->setUserAgent( "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB) Firefox/3.6.6"); $t->setBrowserLanguage('fr'); $t->setLocalTime( '12:34:06' ); $t->setResolution( 1024, 768 ); $t->setBrowserHasCookies(true); $t->setPlugins($flash = true, $java = true, $director = false); // set a Custom Variable called 'Gender' $t->setCustomVariable( 1, 'gender', 'male' ); // If you want to force the visitor IP, or force the server date time to a date in the past, // it is required to authenticate the Tracking request by calling setTokenAuth // You can pass the Super User token_auth or any user with 'admin' privilege on the website $idSite $t->setTokenAuth( $token_auth ); $t->setIp( "134.10.22.1" ); $t->setForceVisitDateTime( '2011-04-05 23:55:02' ); // if you wanted to force to record the page view or conversion to a specific User ID // $t->setUserId( "[email protected]" ); // Mandatory: set the URL being tracked $t->setUrl( $url = 'http://example.org/store/list-category-toys/' ); // Finally, track the page view with a Custom Page Title // In the standard JS API, the content of the tag would be set as the page title $t->doTrackPageView('This is the page title'); ### Example: tracking Ecommerce interactions Here is an example showing how to track Ecommerce interactions on your website, using the PHP Tracking API. Usually, Ecommerce tracking is done using standard Javascript code, but it is very common to record Ecommerce interactions after the fact (for example, when payment is done with Paypal and user doesn't come back on the website after purchase). For more information about Ecommerce tracking in Piwik, check out the documentation: Tracking Ecommerce in Piwik. $t = new PiwikTracker( $idSite = 1, 'http://example.org/piwik/'); // Force IP to the actual visitor IP $t->setTokenAuth( $token_auth ); $t->setIp( "134.10.22.1" ); // Example 1: on a Product page, track an "Ecommerce Product view" $t->setUrl( $url = 'http://www.mystore.com/Endurance-Shackletons-Legendary-Antarctic-Expedition' ); $t->setEcommerceView($sku = 'SKU0011', $name = 'Endurance - Shackleton', $category = 'Books'); $t->doTrackPageView( 'Endurance Shackletons Legendary Antarctic Expedition - Mystore.com'); // Example 2: Tracking Ecommerce Cart containing 2 products $t->addEcommerceItem($sku = 'SKU0011', $name = 'Endurance - Shackleton' , $category = 'Books', $price = 17, $quantity = 1); // Note that when setting a product category, you can specify an array of up to 5 categories to track for this product $t->addEcommerceItem($sku = 'SKU0321', $name = 'Amélie' , $categories = array('DVD Foreign','Best sellers','Our pick'), $price = 25, $quantity = 1); $t->doTrackEcommerceCartUpdate($grandTotal = 42); // Example 3: Tracking Ecommerce Order $t->addEcommerceItem($sku = 'SKU0011', $name = 'Endurance - Shackleton' , $category = 'Books', $price = 17, $quantity = 1); $t->addEcommerceItem($sku = 'SKU0321', $name = 'Amélie' , $categories = array('DVD Foreign','Best sellers','Our pick'), $price = 25, $quantity = 1); $t->doTrackEcommerceOrder($orderId = 'B000111387', $grandTotal = 55.5, $subTotal = 42, $tax = 8, $shipping = 5.5, $discount = 10); ### Note: authenticating with the token_auth To set the visitor IP, or the date and time of the visit, or to force to record the visit (or page, or goal conversion) to a specific Visitor ID, you must call setTokenAuth( $token_auth ). The token_auth must be either the Super User token_auth, or the token_auth of any user with 'admin' permission for the website you are recording data against.</td> </tr> <tr> <td><a href="https://csharpdoc.hotexamples.com/class/Piwik.Tracker/TrackingResponse">TrackingResponse</a></td> <td>Represents the result of a tracking action.</td> </tr> </table> </div> </div> </div> </div> <footer class="footer"> <div class="container"> <div class="row"> <div class="col-md-12" style="text-align: center"> <a href="https://csharp.hotexamples.com/site/trends?type=csharp%7Cc"> Top Classes </a> | <a href="https://csharpdoc.hotexamples.com/doc/map">Documentation</a> | <a href="/site/privacy">Privacy Policy</a> | <a href="https://cpp.hotexamples.com/direct-sales.html">Advertise with us</a> </div> </div> <div class="row"> <div class="col-md-12" style="text-align: center"> <a href="https://hotexamples.com/">PHP</a> | <a href="https://csharp.hotexamples.com/">C# (CSharp)</a> | <a href="https://java.hotexamples.com/">Java</a> | <a href="https://golang.hotexamples.com/">Golang</a> | <a href="https://cpp.hotexamples.com/">C++ (Cpp)</a> | <a href="https://python.hotexamples.com/">Python</a> | <a href="https://javascript.hotexamples.com/">JavaScript</a> | <a href="https://typescript.hotexamples.com/">TypeScript</a> </div> </div> <div class="row"> <div class="col-md-12" style="text-align: center"> <a href="https://csharpdoc.hotexamples.com/namespace/Piwik.Tracker">EN</a> | <a href="https://csharpdoc.hotexamples.com/ru/namespace/Piwik.Tracker">RU</a> | <a href="https://csharpdoc.hotexamples.com/de/namespace/Piwik.Tracker">DE</a> | <a href="https://csharpdoc.hotexamples.com/fr/namespace/Piwik.Tracker">FR</a> | <a href="https://csharpdoc.hotexamples.com/es/namespace/Piwik.Tracker">ES</a> | <a href="https://csharpdoc.hotexamples.com/pt/namespace/Piwik.Tracker">PT</a> | <a href="https://csharpdoc.hotexamples.com/it/namespace/Piwik.Tracker">IT</a> | <a href="https://csharpdoc.hotexamples.com/jp/namespace/Piwik.Tracker">JP</a> | <a href="https://csharpdoc.hotexamples.com/zh/namespace/Piwik.Tracker">ZH</a> | <a href="https://csharpdoc.hotexamples.com/ko/namespace/Piwik.Tracker">KO</a> </div> </div> <div class="row"> <div class="col-md-10 col-md-offset-1"> </div> <div class="col-md-1"> <!--LiveInternet counter--> <script type="text/javascript"><!-- document.write("<a href='//www.liveinternet.ru/click' " + "target=_blank><img src='//counter.yadro.ru/hit?t44.6;r" + escape(document.referrer) + ((typeof (screen) == "undefined") ? "" : ";s" + screen.width + "*" + screen.height + "*" + (screen.colorDepth ? screen.colorDepth : screen.pixelDepth)) + ";u" + escape(document.URL) + ";" + Math.random() + "' alt='' title='LiveInternet' " + "border='0' width='31' height='31'><\/a>"); //--></script><!--/LiveInternet--> </div> </div> </div> </footer> <script src="//ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script> <script src="/assets/30dd86a6f06b64184847037c52c63e07aa3c9a26.js"></script> <script>jQuery(function ($) { jQuery('#search-form').yiiActiveForm([{"id":"searchform-lang","name":"lang","container":".field-searchform-lang","input":"#searchform-lang","enableAjaxValidation":true},{"id":"searchform-search","name":"search","container":".field-searchform-search","input":"#searchform-search","enableAjaxValidation":true,"validate":function (attribute, value, messages, deferred, $form) {yii.validation.required(value, messages, {"message":"Search cannot be blank."});}}], []); });</script></body> </html>