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

Track a pageview with php and update user info and actions with javascript #10422

Closed
agoat opened this issue Aug 22, 2016 · 4 comments
Closed
Labels
duplicate For issues that already existed in our issue tracker and were reported previously.

Comments

@agoat
Copy link

agoat commented Aug 22, 2016

I made a test on my webpage and started tracking with the php and js clients separately. I recognized that I have about 3 times more visits with the php client (probably mainly due to tracking blockers). That's why I want to combine both methods.

Now, when I track the first page view with the php client and the following user actions (outlinks, downloads and events) with the js client, the missing user informations, the php client can´t track (like resolution, plugins, ..), are not updated. It look like these informations are only saved to the database with the first page view request.

I use the following code:

<?php 
require_once "files/PiwikTracker.php";

$piwikTracker = new PiwikTracker($idSite = 1, $apiUrl = 'https://piwik.domain');

$piwikTracker->setTokenAuth('***');
$piwikTracker->setIp(\Environment::get('ip'));

$piwikTracker->doTrackPageView($this->title);

?>
<script type="text/javascript">
  var _paq = _paq || [];
//  _paq.push(['trackPageView']); <-- this results in double pageview
  _paq.push(['enableLinkTracking']);
 // _paq.push(['appendToTrackingUrl', 'cid=<?php echo $piwikTracker->getVisitorId(); ?>']); <-- not necessary
   (function() {
    var u="//piwik.domain/";
    _paq.push(['setTrackerUrl', u+'piwik.php']);
    _paq.push(['setSiteId', '1']);
    var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
    g.type='text/javascript'; g.async=true; g.defer=true; g.src=u+'piwik.js'; s.parentNode.insertBefore(g,s);
  })();
</script>

I wish there would be a function like:

_paq.push(['updatePageView']);
//or
_paq.push(['updateUserInfo']);

to update the already tracked pageview with the missing informations.

This would track all visits (even those without js or with tracking blockers) and, when possible, also the user informations.

I´m not into the piwik core, so I can´t contribute a pull request.

@agoat agoat changed the title Add possibility to track a pageview with php and update user info and action with javascript Track a pageview with php and update user info and actions with javascript Aug 23, 2016
@agoat
Copy link
Author

agoat commented Aug 28, 2016

This theme was discussed many times.
See #9665
Or #9663 and #9711

I think an extra function in the javascript client to update missing data will be a good solution.

@agoat
Copy link
Author

agoat commented Oct 9, 2016

See also #9963

@mattab
Copy link
Member

mattab commented Nov 11, 2016

Thanks @agoat - do you mind pasting your comment in the main issue: #9665
i'll close this one as duplicate

@mattab mattab closed this as completed Nov 11, 2016
@mattab mattab added the duplicate For issues that already existed in our issue tracker and were reported previously. label Nov 11, 2016
@mattab
Copy link
Member

mattab commented Mar 25, 2020

This issue might be even better idea/ easier to use: #13023

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate For issues that already existed in our issue tracker and were reported previously.
Projects
None yet
Development

No branches or pull requests

2 participants