[quote=vipsoft @ Jul 22 2009, 02:21 PM]There shouldn’t be any conflict. First, the tracker encodes the URL. Second, the tracker calls piwik.php (not index.php) in a separate request.
Maybe you could post your “diff” of core/Tracker/Visit.php, so that we can figure out what’s wrong with your hack.[/quote]
But when I view index.php, piwik always log the data in piwik_log_visit.
This is my code, I add 2 function in the class Piwik_Tracker_Visit.
class Piwik_Tracker_Visit implements Piwik_Tracker_Visit_Interface {
.......
.......
/**
* ECommerce Code
*/
function getECommerceVars($data,$key,$default = 'NULL') {
return (isset($data[$key]) && $data[$key] !== '') ? "'".$data[$key]."'" : $default;
}
/**
* ECommerce code
*/
function logECommerceData($idvisit) {
//receive data of e_commerce
$rData = Piwik_Common::getRequestVar('data',NULL);
//check whther there is data of e_commerce, if no data, return
if (empty($rData)) return;
$rData = html_entity_decode($rData);
$data = json_decode( $rData, true );
//if Piwik_Common::getRequestVar('eCommerce',NULL) is null, it is
//said this data is not send by trackLink, so we need ignore these datas
if (Piwik_Common::getRequestVar('eCommerce',NULL) === NULL) return;
$reference_commande=
$this->getECommerceVars($data,'reference_commande');
$montant_total_TTC_commande =
$this->getECommerceVars($data,'montant_total_TTC_commande');
$montant_total_taxes_commande =
$this->getECommerceVars($data,'montant_total_taxes_commande');
$montant_total_frais_port_commande =
$this->getECommerceVars($data,'montant_total_frais_port_commande');
$email_client = $this->getECommerceVars($data,'email_client');
$idclient = $this->getECommerceVars($data,'idclient');
$ville_livraison_commande =
$this->getECommerceVars($data,'ville_livraison_commande');
$pays_livraison_commande =
$this->getECommerceVars($data,'pays_livraison_commande');
$region_livraison_commande =
$this->getECommerceVars($data,'region_livraison_commande');
$apporteur_ayany_permis =
$this->getECommerceVars($data,'apporteur_ayany_permis');
$mot_clef_ayant_permis =
$this->getECommerceVars($data,'mot_clef_ayant_permis');
$reference_article =
$this->getECommerceVars($data,'reference_article');
$nom_article = $this->getECommerceVars($data,'nom_article');
$gamme_article = $this->getECommerceVars($data,'gamme_article');
$prix_article = $this->getECommerceVars($data,'prix_article');
$nombre_article = $this->getECommerceVars($data,'nombre_article');
$idsite = Piwik_Common::getRequestVar('idsite');
$server_time = "'".date('Y-m-d G:i:s',time())."'";
//insert values into tables_prefix_log_ecommerce, make query firet
$query = "INSERT INTO ".Piwik_Common::prefixTable('log_ecommerce').
"(idsite,
idvisit,
server_time,
reference_commande,
montant_total_TTC_commande,
montant_total_taxes_commande,
montant_total_frais_port_commande,
email_client,
idclient,
ville_livraison_commande,
pays_livraison_commande,
region_livraison_commande,
apporteur_ayany_permis,
mot_clef_ayant_permis,
reference_article,
nom_article,
gamme_article,
prix_article,
nombre_article)
VALUES
($idsite,
$idvisit,
$server_time,
$reference_commande,
$montant_total_TTC_commande,
$montant_total_taxes_commande,
$montant_total_frais_port_commande,
$email_client,
$idclient,
$ville_livraison_commande,
$pays_livraison_commande,
$region_livraison_commande,
$apporteur_ayany_permis,
$mot_clef_ayant_permis,
$reference_article,
$nom_article,
$gamme_article,
$prix_article,
$nombre_article)";
//run the query
Piwik_Tracker::getDatabase()->query($query);
}
}
And I add the code in to run getECommerceVars in function $this->handle:
class Piwik_Tracker_Visit implements Piwik_Tracker_Visit_Interface {
.....
......
public function handle() {
......
.......
//ECommerce Code
$this->logECommerceData($this->visitorInfo['idvisit']);
//End of ECommerce Code
// update the cookie with the new visit information
$this->updateCookie();
// record the goals if applicable
if($someGoalsConverted)
{
$goalManager->setCookie($this->cookie);
$goalManager->recordGoals($this->visitorInfo, $action);
}
unset($goalManager);
unset($action);
}
.....
......
}