Ran into the need to be able to use both APIs together for better accuracy in what various ad / search platforms report as clicks to our sites.
Example PHP API Tracking code:
$piwik->setTokenAuth( $this->token_auth ); // We're behind a load balancer, have to force the client IP and not the server's $piwik->setIp( $this->ipaddress ); $piwik->setLocalTime( date('H:i:s', time()) ); $piwik->setCustomVariable( 1, 'keyword', $this->keyword_name, 'visit' ); $piwik->setCustomVariable( 2, 'variant', $this->variant_name, 'visit' ); //Manually set our campaign $piwik->setUrl( $piwik->pageUrl .= strpos($piwik->pageUrl, '?') !== false ? '&cam='.$this->campaign : '?cam='.$this->campaign ); //Allow Abandonment Tracking $piwik->setTrackAbandons( true ); $click = $piwik->doTrackPageView('Bounce');
I checked out the trunk and applied my changes to the latest revisions. Patches attached.
Attachment: condensed Patches to single file
Thanks for the ticket. Can you please put all patches into one patch file, and explain the changes you made and what problem they solve? thx
No problem - This was to resolve 'missing' visits that were recorded by our ad platforms but were never recorded in Piwik. The culprit seems to be people 'abandoning' before the page loads and the JS code can fire. The problem was diagnosed by parsing access logs for our sites and for our piwik install respectively.
This patch does the follow:
This now allows for more accurate tracking as compared to the ad platforms, and allows us to measure Abandonment rate - we can see how many users leave before the page fully loads / the JS tracking code fires. Possibly beneficial in #1700 - Time of the request versus DOMReady?
Currently, this requires the use of the 'trust_visitors_cookie' config option.
Thanks for the patch. This is an interesting idea, we will not commit it in trunk, but maybe others will find this patch useful.
Milestone 1.8.x Piwik 1.8.x deleted