Here is the code we use in the WorldPay callback script:
// – Piwik Tracking API init –
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
// Mandatory: set the URL being tracked
// Sends Tracker request via http
$piwikTracker->doTrackPageView(‘Oursite.com Post Worldpay’);
// You can also track Goal conversions
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!