We have a fairly complex tracking requirement involving goal tracking post WorldPay that we cannot get working in Piwik.
The scenario is this:
Referring site --> Our Site 1 --> Our Shop Site --> WorldPay --> post WorldPay aggregator on Our Site 2.
To make it simpler for development we’ve shortened this down to:
Referring site --> Our Site 1 --> post WorldPay dummy on Our Site 2.
When the referral arrives at Our Site 1 we set a custom variable using JavaScript. When we arrive post WorldPay we would like to check this custom variable and if set track a goal. We cannot get this working.
There is a complication. While Our Site 1 and Our Shop Site can use JavaScript the post WorldPay has to use the PiwikTracker.php API.
Our Site 1 is using the following JavaScript snippet:
<script type="text/javascript">
// < ![CDATA[
var piwikBaseURL = (("https:" == document.location.protocol) ? "https://www.OurSite2.com/piwik/" : "http://www.OurSite2.com/piwik/" );
document.write(unescape("%3Cscript src='" + piwikBaseURL + "piwik.js' type='text/javascript'%3E%3C/script%3E" ));
// ]]>
</script>
<script type="text/javascript">
// < ![CDATA[
try
{
var piwikLocalTracker = Piwik.getTracker(piwikBaseURL + "piwik.php", 9);
piwikLocalTracker.setCustomVariable(1, "visitOriginator", "DCBF", "visit" ) ;
piwikLocalTracker.trackPageView();
piwikLocalTracker.enableLinkTracking();
}
catch( err ) {}
// ]]>
</script>
The post WorldPay script is using PiwikTracker thus:
$dcbfPiwikTracker = new PiwikTracker(9);
// Mandatory: set the URL being tracked
$dcbfPiwikTracker->setUrl('http://OurSite2.com/post/postWorldPay.php' );
$custVarVals = $dcbfPiwikTracker->getCustomVariable(1);
if (($custVarVals[0] == "visitOriginator" ) && ($custVarVals[1] == "DCBF" ))
{
$dcbfPiwikTracker->doTrackGoal(1, $totalAmount);
}
We were logging to file but for some reason that’s not being called by this process or it’s stopped working. But I’m happy to collect any debug info required. To be honest it makes my brain hurt getting my hear around this! Please can someone help?