@anonymous-matomo-user opened this Issue on October 12th 2011

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.
Keywords: interesting

@anonymous-matomo-user commented on October 12th 2011


@anonymous-matomo-user commented on October 12th 2011
@anonymous-matomo-user commented on October 12th 2011


@anonymous-matomo-user commented on October 12th 2011

Attachment: condensed Patches to single file

@mattab commented on October 12th 2011 Member

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

@anonymous-matomo-user commented on October 12th 2011

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:

  • Allows setting the first party _pk_id cookie and a _pk_abdn cookie from PiwikTracker.php
  • Checks if the _pk_abdn cookie exists in the JS tracking code and adds &_abdn=1 to the request to Piwik
  • When the cookie is detected, we update the Config settings of the visitor to update the config_id and settings PHP can't detect, as well as updates the first Action of the visit, instead of creating a new action.

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.

@mattab commented on November 28th 2011 Member

Thanks for the patch. This is an interesting idea, we will not commit it in trunk, but maybe others will find this patch useful.

@mattab commented on December 16th 2012 Member

Milestone 1.8.x Piwik 1.8.x deleted

@mattab commented on October 24th 2013 Member

This has been implemented! see: #4239

This Issue was closed on October 24th 2013
Powered by GitHub Issue Mirror