Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using PHP Tracking API with Javascript Tracking API #2699

Closed
anonymous-matomo-user opened this issue Oct 12, 2011 · 9 comments
Closed

Using PHP Tracking API with Javascript Tracking API #2699

anonymous-matomo-user opened this issue Oct 12, 2011 · 9 comments
Labels
Enhancement For new feature suggestions that enhance Matomo's capabilities or add a new report, new API etc. wontfix If you can reproduce this issue, please reopen the issue or create a new one describing it.
Milestone

Comments

@anonymous-matomo-user
Copy link

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
Copy link
Author

Attachment:
piwik.js.patch

@anonymous-matomo-user
Copy link
Author

Attachment:
PiwikTracker.php.patch

@anonymous-matomo-user
Copy link
Author

Attachment:
Visit.php.patch

@mattab
Copy link
Member

mattab commented Oct 12, 2011

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
Copy link
Author

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.

@anonymous-matomo-user
Copy link
Author

Attachment: condensed Patches to single file
abandonment.patch

@mattab
Copy link
Member

mattab commented Nov 28, 2011

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
Copy link
Member

mattab commented Dec 16, 2012

Milestone 1.8.x Piwik 1.8.x deleted

@mattab
Copy link
Member

mattab commented Oct 24, 2013

This has been implemented! see: #4239

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement For new feature suggestions that enhance Matomo's capabilities or add a new report, new API etc. wontfix If you can reproduce this issue, please reopen the issue or create a new one describing it.
Projects
None yet
Development

No branches or pull requests

2 participants