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

Enable tracking performance and browser plugins without pageview (offer ability to force a specific page view ID in JS tracker) #16942

Closed
JE4GLE opened this issue Dec 13, 2020 · 13 comments
Labels
Enhancement For new feature suggestions that enhance Matomo's capabilities or add a new report, new API etc. not-in-changelog For issues or pull requests that should not be included in our release changelog on matomo.org.

Comments

@JE4GLE
Copy link
Contributor

JE4GLE commented Dec 13, 2020

Hello,

I use a combination of the HTTP Tracking API with PHP and the JavaScript Tracker. The PHP side tracks page views, ECommerce and other events, so that every page view and transaction is reported and not lost by users blocking the JavaScript tracker. In addition to the PHP side, the JavaScript tracker tracks the rest, like content tracking. This has the disadvantage that page views are not tracked using the JavaScript tracker and I lose important data like Performance tracking (Plugins are not so important, but share the principle).

My suggestion would be to allow sending performance and browser plugins without a page view. Maybe using an event or a separate method like trackPerformance(), which should not be used in combination with trackPageView([customTitle]).

Thank you!

@tsteur
Copy link
Member

tsteur commented Dec 13, 2020

Hi @JE4GLE

for page performance metrics this might be already the case if you track for example an event on the page. Then Matomo would currently attribute this to the page view. However, this can only work if you track a page view ID server side. The problem is that you can't really know what page view ID to send because it's randomised in JavaScript tracker. So a method to force a specific page view ID to be used should be all that's needed here. Then any event or content tracking request would set the correct page performance metrics on the page view.

@tsteur tsteur added the Enhancement For new feature suggestions that enhance Matomo's capabilities or add a new report, new API etc. label Dec 13, 2020
@tsteur tsteur changed the title Enable tracking performance and browser plugins without pageview Enable tracking performance and browser plugins without pageview (offer ability to force a specific page view ID in JS tracker) Dec 13, 2020
@JE4GLE
Copy link
Contributor Author

JE4GLE commented Dec 13, 2020

Thank you @tsteur

So I would call this method setPageView with my pageview ID in my PHP Tracker and the next event I send using the JavaScript tracker would automatically attach Performance Metrics data to the next event?
Wouldn't it be possible to just send a page view again using JS and because of the same pageview ID it wouldn't track 2 page views? This way, you would have a future-proof way of using the combined advantages of the JS page view and the PHP page view.

@tsteur
Copy link
Member

tsteur commented Dec 14, 2020

So I would call this method setPageView with my pageview ID in my PHP Tracker and the next event I send using the JavaScript tracker would automatically attach Performance Metrics data to the next event?

Exactly.

Wouldn't it be possible to just send a page view again using JS and because of the same pageview ID it wouldn't track 2 page views? This way, you would have a future-proof way of using the combined advantages of the JS page view and the PHP page view.

I'm not 100% sure but I would very much expect in this case it would record two page views then. In this case you could also simply only track page views through JS? But that wouldn't help I guess when some requests are blocked. It be something to think about though 👍 The problem is it would need a new SELECT DB query on every tracking request to make this work and this can add again quite some load onto the system for a rather rarely used feature. Ideally things would work maybe the other way where data is tracked using JS and if that's not successful then using PHP but this again can take a bit of work and might have downsides.

A very simple solution be to have an option to force a specific pageViewId when calling trackPageView. This would already solve the problem but there are also like you suggest many other additional ways possible.

@Atala
Copy link

Atala commented Feb 2, 2021

Hey

I got the same problem here (I think).

If I understand well, a simpler solution would be to be able to access the page view ID from javascript code (configIdPageView, getConfigIdPageView), so you can send it along to your PHP/backend code and then fill the pv_id param to your backend track request.

However it seems to me that I can't access this property on the global Matomo object or on the Matomo.tracker objects. (although it seems public from the code).

Would that be a solution ?

@JE4GLE
Copy link
Contributor Author

JE4GLE commented Feb 24, 2021

Hey

I got the same problem here (I think).

If I understand well, a simpler solution would be to be able to access the page view ID from javascript code (configIdPageView, getConfigIdPageView), so you can send it along to your PHP/backend code and then fill the pv_id param to your backend track request.

However it seems to me that I can't access this property on the global Matomo object or on the Matomo.tracker objects. (although it seems public from the code).

Would that be a solution ?

I don't think, this would be an advantage, because you would have to trigger the pageview request with PHP after the page has loaded using an async call. Orherwise you can't send the pageview ID from JavaScript to PHP.
The best way would be to always register the pageview using PHP and provide the id to JavaScript during the page generation.

@JE4GLE
Copy link
Contributor Author

JE4GLE commented Mar 23, 2021

Any update here? :)

@tsteur
Copy link
Member

tsteur commented Mar 23, 2021

@JE4GLE the feature is not on our roadmap currently. If you're familiar with PHP/JS feel free to create a pull request and we'll be happy to review. We have various docs on https://developer.matomo.org/ , for the tracker we have for example https://developer.matomo.org/guides/jstracker-core

@JE4GLE
Copy link
Contributor Author

JE4GLE commented Jun 8, 2021

I've made the following change in a forked version: https://github.com/Promatur/matomo/commit/a40b6a3e771220d62efd9e1526ed6b272ab36353

I'm not really experienced with Matomo, could you have a quick look please?

@tsteur
Copy link
Member

tsteur commented Jun 8, 2021

I haven't tested but it looks like this could work @JE4GLE 👍

@JE4GLE
Copy link
Contributor Author

JE4GLE commented Jun 8, 2021

@tsteur Thanks! Do I have to do anything else or do I just submit a Pull Request?

@tsteur
Copy link
Member

tsteur commented Jun 8, 2021

I think there's a semicolon missing after the setPageViewId function but someone would be reviewing it anyway. So creating a PR should be it 👍

@heurteph-ei
Copy link

This seems to have been released in v4.4.0.
So the ticket can be closed, can't it?

@tsteur
Copy link
Member

tsteur commented Aug 4, 2021

👍

@tsteur tsteur closed this as completed Aug 4, 2021
@tsteur tsteur added the not-in-changelog For issues or pull requests that should not be included in our release changelog on matomo.org. label Aug 4, 2021
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. not-in-changelog For issues or pull requests that should not be included in our release changelog on matomo.org.
Projects
None yet
Development

No branches or pull requests

4 participants