We’ve just started with Piwik because Google Analytics doesn’t seem able to track events in the WorldPay callback scripts. When calling back to a site WorldPay doesn’t allow JavaScript nor it appears image tracking. It does however allow PHP calls to be made. We have a number of sites feeding into two shop sites. The WorldPay callback scripts are on just one of these shop sites. We want to be track visitors from specific landing pages with the goal set as a WorldPay callback with SUCCESS is a conversion.
Here is the code we use in the WorldPay callback script:
// – Piwik Tracking API init –
require_once “…/piwik/PiwikTracker.php”;
PiwikTracker::$URL = ‘oursite.com’;
$piwikTracker = new PiwikTracker(1);
// 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);
// Mandatory: set the URL being tracked
$piwikTracker->setUrl(‘oursite.com’ );
// Sends Tracker request via http
$piwikTracker->doTrackPageView(‘Oursite.com Post Worldpay’);
// You can also track Goal conversions
$piwikTracker->doTrackGoal(1, $totalAmount);
$piwikTracker->doTrackGoal(3, $totalAmount);
$piwikTracker->doTrackGoal(4, $totalAmount);
The call to doTrackPageView(…) appears to be working. The calls to doTrackGoal(…) appear to be not working. Although the goals in the Goals Overview page do have numbers they appear random! For example Goal 3 in the Goals Overview page has a count of 1, but in the database table piwik_log_conversion I see 9. So either 8 of these are not seen as valid conversions for some reason or the Goals Overview page is just not counting correctly.
I have loaded the code into NetBeans and with the PHP debugger I can see it going to PiwikTracker::sendRequest(…) but it never seems to get to core/Tracker/GoalManager.php. I’m not familiar with curl so I’m not sure how relevant the call to curl_exec in sendRequest(…) is. Moreover it never gets to set any Cookies since the cookie array is not empty.
I have configured Piwik to output debug information to a file and I can see lines like:
INSERT IGNORE INTO piwik_log_conversion (idvisit, idsite, idvisitor, server_time, location_country, location_continent, visitor_returning, visitor_days_since_first, visitor_days_since_order, visitor_count_visits, referer_type, referer_name, referer_keyword, referer_visit_server_date, idgoal, url, revenue, idaction_url, idlink_va, buster) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?), one for each call to doTrackGoal(…) .
I have many questions! For a start how does it manage to INSERT INTO piwik_log_conversion when apparently it doesn’t execute any code that actually does this. Is curl a messaging system? If so where is the message handler? Is there a way of expanding the VALUES so they don’t just appear as ‘?’ ?
But more important is why are the stats incorrect in the Goals Overview page??
Please be gentle, we are newbies!