API Ανίχνευσης του Piwik

Ο βασικός τρόπος καταγραφής δεδομένων στο Piwik είναι η χρήση κώδικα Ανίχνευσης Javascript. Αυτό λετιουργεί καλά για τους περισσότερους χρήστες όπου η επικόλληση ενός κώδικας Javascript στο υποσέλιδο της σελίδας δεν είναι πρόβλημα.

Εμφανίζονται συχνά περιπτώσεις όπου η Javascript δεν μπορεί να χρησιμοποιηθεί: σελίδες Ebay, σελίδες MySpace, αλλά και Εφαρμογές Λογισμικού, εφαρμογές iPhone ή Android, ιστοσελίδες για κινητά, κλπ.

Σε αυτές τις περιπτώσεις, μπορείτε να χρησιμοποιήσετε εναλλακτικούς τρόπους καταγραφής επισκεπτών, επισκέψεων, μετατροπών σελίδων και Στόχων στο Piwik:

  • Απλός Ανιχνευτής Εικόνων
  • Βελτιωμένος Ανιχνευτής Εικόνων
  • API Ανίχνευσης PHP του Piwik

Αντικαταστήστε παρακάτω το {$IDSITE} με το ID της ιστοσελίδας σας στο Piwik και αντικαταστήστε το http://www.example.org/piwik/ με το URL του Piwik σας.

Image Tracker code

The Image Tracker code can be used when Javascript is not allowed.

Some websites like MySpace or eBay will not allow users to add Javascript to their profile but accept HTML. In this case, you can still track visits with Piwik using the Image Tracker.
Note: the code doesn't use Javascript so Piwik will not be able to track some user information such as search keywords, referrers, screen resolutions, browser plugins and page titles.

<!-- Piwik Image Tracker -->
<img src="http://www.example.org/piwik/piwik.php?idsite={$IDSITE}&amp;rec=1" style="border:0" alt="" />
<!-- End Piwik -->

The following parameters can also be passed to the image URL:
  • rec - (required) The parameter &rec=1 is required to force the request to be recorded
  • idsite - (required) Defines the Website ID being tracked
  • action_name - Defines the custom Page Title for this page view
  • urlref - The Referrer URL: must be set to the referrer URL used before landing on the page containing the Image tracker. For example, in PHP this value is accessible via
    $_SERVER['HTTP_REFERER']
  • idgoal - The request will trigger the given Goal
  • revenue - Used with idgoal, defines the custom revenue for this conversion
  • and more! - There are many more parameters you can set beyond the main ones above. See the Tracking API documentation page.

Piwik Tracking API (Advanced users)

It is also possible to call the Piwik Tracking API using your favorite programming language.

The Piwik Tracking API allows to trigger visits (page views and Goal conversions) from any environment (Desktop App, iPhone or Android app, Mobile website, etc.).

We currently provide a PHP client to call the API from your PHP projects. If you would like to contribute a version of the client in another programming language (Python, Java, Ruby, Perl, etc.) please create a ticket in our developer area (please attach the client code to the ticket).

Follow these instructions to get started with the Tracking API:

  • Click here to download the file PiwikTracker.php
  • Upload the PiwikTracker.php file in the same path as your project files
  • Copy the following code, then paste it onto every page you want to track. <?php
    // -- Piwik Tracking API init --
    require_once "/path/to/PiwikTracker.php";
    PiwikTracker::$URL = 'http://www.example.org/piwik/';
    ?>
  • Choose a Tracking method, then paste the code onto every page you want to track.
    • Method 1: Advanced Image Tracker

      The client is used to generate the tracking URL that is wrapped inside a HTML <img src=''> code.
      Paste this code before the </body> code in your pages. <?php
      // Example 1: Tracks a pageview for Website id = {$IDSITE}
      echo '<img src="'. str_replace("&","&amp;", Piwik_getUrlTrackPageView( $idSite = {$IDSITE}, $customTitle = 'This title will appear in the report Actions > Page titles')) . '" alt="" />';
      // Example 2: Triggers a Goal conversion for Website id = {$IDSITE} and Goal id = 2
      // $customRevenue is optional and is set to the amount generated by the current transaction (in online shops for example)
      echo '<img src="'. str_replace("&","&amp;", Piwik_getUrlTrackGoal( $idSite = {$IDSITE}, $idGoal = 2, $customRevenue = 39)) . '" alt="" />';
      ?>

      The Advanced Image Tracker method is similar to using the standard Javascript Tracking code. However, some user settings are not detected (resolution, local time, plugins and cookie support).

    • Method 2: HTTP Request

      You can also query the Piwik Tracker API remotely via HTTP. This is useful for environment where you can't execute HTML nor Javascript.
      Paste this code anywhere in your code where you wish to track a user interaction. <?php
      $piwikTracker = new PiwikTracker( $idSite = {$IDSITE} );
      // You can manually set the visitor details (resolution, time, plugins, etc.)
      // See all other ->set* functions available in the PiwikTracker.php file
      $piwikTracker->setResolution(1600, 1400);

      // Sends Tracker request via http
      $piwikTracker->doTrackPageView('Document title of current page view');

      // You can also track Goal conversions
      $piwikTracker->doTrackGoal($idGoal = 1, $revenue = 42);
      ?>

API Κλάσης Ανίχνευσης PHP του Piwik

Διαβάστε την τεκμηρίωση API για την κλάση PiwikTracker.

Περισσότερες πληροφορίες

Δείτε επίσης τις σχετικές προσθήκες στις ΣΑΕ

    No comments have been added yet...

Σχολιάστε

Υποβολή σχολίου