La modalità standard di archiviazione dei dati in Piwik è l’uso del tag di Tracciamento in Javascript . Questo funziona bene per la maggior parte dei siti, quando inserire del codice Javascript nel footer della pagina non è un problema.
Ci sono però altri casi frequenti in cui Javascript non può essere usato: pagine di Ebay, di MySpace, oppure Applicazioni Software, o per iPhone o Android, siti web per dispositivi mobile, ecc.
In questi casi, potete usare modalità alternative per registrare i visitatori, le visite, le pagine e le conversioni dei Goal in Piwik:
Nella seguente stringa, sostituite {$IDSITE} con l’ID del vostro sito web Piwik, e sostituite http://www.example.org/piwik/ con l’URL del vostro Piwik.
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}&rec=1" style="border:0" alt="" />
<!-- End Piwik -->
$_SERVER['HTTP_REFERER']
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:
<?php
// -- Piwik Tracking API init --
require_once "/path/to/PiwikTracker.php";
PiwikTracker::$URL = 'http://www.example.org/piwik/';
?>
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("&","&", 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("&","&", 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).
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);
?>
Leggete la documentazione sulle API riguardo alla classe del PiwikTracker.
Leggi anche queste FAQ collegate