Hi,
I've checked the plugin config values in the database.
It didn't change at all after I resaved the config values.
uaCode=UA-xxxxxxx
trackEcommerce=1
trackConversions=0
conversionCode=
uaScript=
I've checked the code and it doesn't make sense to me.
Insdie the getCode function, there is a part that testing with old ga code, if '$this->purchace' value is false.
Here:
function getCode()
{
// load needed ORDER information
if ($this->purchase) $this->loadOrderData();
$vmTracking = ($this->purchase && $this->_params->get('trackEcommerce', 1)) ? $this->getVMTrackCode() : '';
$cTrack = $this->purchase && $this->_params->get('trackConversions', 1);
// = sprintf($this->_params->get('uaScript', $this->uaScript), $this->_params->get('uaCode', ''), $vmTracking);
$code = '';
// place to add conversion tracking code
if ($cTrack) {
$code .= "<div id=\"awtracking\"></div>\n";
}
if (!$this->purchase) {
// standard tracking code
$uaScript = $this->_params->get('uaScript', $this->uaScript);
if (strlen(trim($uaScript)) == 0) $uaScript = $this->uaScript;
$code .= sprintf($uaScript, $this->_params->get('uaCode', ''));
}
//if ($this->purchase) {
// test with old code
else {
$code .= $this->uaScriptOld;
// generate GA tracking
$code .= "<script type=\"text/javascript\">\n";
$code .= " try {\n";
$code .= " function GATrack() {\n";
//$code .= $vmTracking . "\n";
$code .= sprintf(" var pageTracker = _gat._getTracker(\"%s\");\n", $this->_params->get('uaCode', ''));
$code .= " pageTracker._trackPageview();\n";
$code .= $vmTracking = ($this->purchase && $this->_params->get('trackEcommerce', 1)) ? $this->getVMTrackCodeOld() : '';
//$code .= " alert('click!'); return false;\n";
$code .= sprintf($this->_params->get('uaScriptOld', $this->uaScriptOld), $track);
// if conversion tracking
if ($cTrack) {
$code .= " document.getElementById('awtracking').innerHTML = GATrackCode;\n";
}
//$code .= " alert('clicked!'); return false;\n";
$code .= " }\n";
// generate conversion tracking
if ($cTrack) {
$cCode = $this->_params->get('conversionCode', '');
$cCode = str_replace(array("\r\n", "\n", "script"), array(" ", " ", "scr' + ' ipt"), $cCode);
$code .= " var GATrackCode = '" . str_replace('%s', $this->totals['order_total'], $cCode) . "';\n";
}
// map code generation to button click
$code .= " document.adminForm.formSubmit.addEventListener('click', GATrack, true);\n";
$code .= " } catch(err) {}\n";
$code .= "</script>\n";
}
return $code;
}
Thanks for your help.
- Seiko