matomo-org / matomo

Empowering People Ethically with the leading open source alternative to Google Analytics that gives you full control over your data. Matomo lets you easily collect data from websites & apps and visualise this data and extract insights. Privacy is built-in. Liberating Web Analytics. Star us on Github? +1. And we love Pull Requests!
https://matomo.org/
GNU General Public License v3.0
19.9k stars 2.65k forks source link

Page Overlay doesn't seem to work when tracking code Matomo URL is different from Matomo GUI URL (e.g. proxy configuration) #18291

Open peterbo opened 3 years ago

peterbo commented 3 years ago

Expected Behavior

When opening the Page Overlay feature for a given URL, the Page Overlay should open and display the corresponding numbers and overlay data for a given page.

Current Behavior

Currently, if the Matomo tracking URL is different from the Matomo GUI URL (e.g. in proxy environments), Overlay does open, but keeps the loading screen in the left frame (no data will be loaded), and no overlay data is shown in the website view frame.

Possible Solution

Steps to Reproduce (for Bugs)

  1. Have the Matomo Tracking URL implemented in the website via URL A
  2. Have the Matomo Reporting GUI accessible via URL B
  3. try to open page overlay

Your Environment

sgiehl commented 3 years ago

@peterbo could you maybe check if there are failing requests when opening the overlay? Maybe there are some CORS headers in place that are causing issues?

heurteph-ei commented 3 years ago

@peterbo Other possible bug source: the site is in HTTP and Matomo in HTTPS. Your browser won't allow this (it won't allow display an HTTP frame in an HTTPS page)...

mikkeschiren commented 2 years ago

I can confirm this bug. Manually overriding pPiwikRoot is fixing the issue, as pPiwikRoot get the domain of URL A instead of URL B. Still present in 4.6.2. (all sites in HTTPS)

tomper00 commented 2 years ago

I have been looking into this today again. We would really need to implement a solution where the "tracker domain" like this plugin from @mikkeschiren does https://github.com/digitalist-se/TrackerDomain and use that variable to handle this. I will for now create a patch for the Overlay plugin to make our environment work with a separate tracker domain.
I really think this should be part of core in the end (both the TrackerDomain and the changes in the Overlay plugin and potentially a lot of other plugins that might have similar issues.

mikkeschiren commented 1 year ago

Started to dig into this again, but having a hard time figuring out where pPiwikRoot URL is coming from?

sgiehl commented 1 year ago

@mikkeschiren It is passed through from the tracking code. In piwik.js the overlay scripts are initiated here: https://github.com/matomo-org/matomo/blob/4.x-dev/js/piwik.js#L6588

It also provides the configTrackerUrl as parameter, which is in the end used as pPiwikRoot.

mikkeschiren commented 1 year ago

Why is the main reason behind that the code for the display of the Overlay is in the piwik.js? As that mainly is for tracking, should code not used for tracking, be part of that file? I am sure there is a good reason, but I just doesn't understand it :)

sgiehl commented 1 year ago

@mikkeschiren Haven't looked in detail, but I think it wouldn't be possible to inject custom javascript into a website shown in an iframe. As the tracking code is always included we use it to load additional javascript for the overlay features.

mikkeschiren commented 1 year ago

Ah, that makes sense.

John98Zakaria commented 5 months ago

Are there any updates regarding this issue ? (Matomo support asked me to comment here :sweat_smile: )

You are most welcome to comment on the GitHub issue as the more requests we get for this to be resolved, the more priority is given to the issue.

jannikschaper commented 5 months ago

+1

9joshua commented 5 months ago

Same issue for another customer. I can see the Page Overlay feature is trying to display the customer's site in an iFrame but the site does not allow cross origin requests... image