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.89k stars 2.65k forks source link

Email reports with a CSV file should use the friendly column names ("Visits" instead of "nb_visits") #17122

Open mattab opened 3 years ago

mattab commented 3 years ago

When creating an email report in the "CSV" format, the CSV file uses "raw" column names, like this:

Visits Summary
nb_uniq_visitors,nb_visits,nb_actions,max_actions,nb_actions_per_visit,avg_time_on_site,bounce_rate
8068,8146,21495,291,2.6,00:03:23,60%

Here is the top of the CSV file:

Screenshot from 2021-01-26 12-37-29

Maybe it would be easier for most people If we added translateColumnNames=1 to the CSV report generator request, so that the output would go to the more friendly format eg:

Visits Summary
Label,Unique visitors,Visits,Actions,Users,Maximum actions in one visit,Total time spent by visitors (in seconds),Bounces,Visits with Conversions 
Germany,1781,1788,4850,0,66,409926,1032,709,613,613

also it seems that even when downloading any report in Matomo it also sets translateColumnNames=1? (I've been trying but can't find a way to generate the CSV report with "raw" columns from the "Export this data" icon below reports. ). So doing this for email reports as well would maybe make it overall more consistent.

hamburnyog commented 3 years ago

Hi, I would love to take a stab at this issue. I am learning how to contribute to open source and this looks like an amazing learning opportunity! Please let me know how can I start. 😄

sgiehl commented 3 years ago

@hamburnyog Happy to hear you want to contribute. How familiar are you with Matomo already? The issue is about email reports, so the correct plugin to start would be the ScheduledReports plugin. The reports are generated in the API, so guess that needs to be adjusted somehow. See https://github.com/matomo-org/matomo/blob/4.x-dev/plugins/ScheduledReports/API.php#L317

hamburnyog commented 3 years ago

@hamburnyog Happy to hear you want to contribute. How familiar are you with Matomo already? The issue is about email reports, so the correct plugin to start would be the ScheduledReports plugin. The reports are generated in the API, so guess that needs to be adjusted somehow. See https://github.com/matomo-org/matomo/blob/4.x-dev/plugins/ScheduledReports/API.php#L317

TBH, I just found out about matomo but I did similar reporting tasks before. Thanks for this response, gonna read this.

atom-box commented 1 year ago

Since this feature already exists as an API option, perhaps implementation for the emailed reports can leverage the existing code that is used in the API translateColumnNames option?

For example here is the syntax in the context of an example API call.

https://www.example.com/matomo/index.php?module=API&format=CSV&idSite=13.=day&date=today&method=CustomReports.getCustomReport&idCustomReport=91&reportUniqueId=CustomReports_getCustomReport_idCustomReport--91&expanded=1&token_auth=foobarbaz&filter_limit=10&language=en&translateColumnNames=1
atom-box commented 1 year ago

We had a request for this feature last week. The user asked:

(We) want this "friendly" column name report as part of the Email Report functionality, and as observed working with the Matomo tool

And further:

some labels are nb_hits, nb_visits which are the metrics for Number of views on this page and Number of Visits (30 min of inactivity considered a new visit). We want the above metrics to be labelled as the entire string "Number of views" and "Number of Visits" accordingly.