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

Scheduled Reports with All Websites: Ecommerce Orders & Revenue displayed only when a website is e-commerce #3798

Open
julienmoumne opened this issue Mar 5, 2013 · 2 comments
Labels
Task Indicates an issue is neither a feature nor a bug and it's purely a "technical" change.

Comments

@julienmoumne
Copy link
Member

Context

The issue described here came-up while updating the MultiSites API to support the development of the MobileMessaging Plugin :


refs #389

  • new API method to retrieve only one Piwik site : Piwik_MultiSites_API->getOne()
  • per Send reports via SMS #2708 description, Piwik_MultiSites_API methods now support a new parameter named enhanced. When activated, Goal Conversions, eCommerce Conversions and eCommerce Revenue along with their evolution will be included in the API output.
  • API metrics refactored in (@ignored)Piwik_MultiSites_API->getApiMetrics()
  • Metadata now returns 12 metrics : nb_visits, visits_evolution, nb_actions, actions_evolution, revenue, revenue_evolution, nb_conversions, nb_conversions_evolution, orders, orders_evolution, ecommerce_revenue, ecommerce_revenue_evolution

Issue Details

The issue is two-sided.

1) Metrics not defined in Metadata are not returned by API.getProcessedReport()

Piwik_API_API::getInstance()->getProcessedReport() is used by scheduled reports to retrieve the list of metrics to display. It also returns their values.

Metrics returned by Piwik_API_API::getInstance()->getProcessedReport() are defined based on the report <metrics/> metadata definition. Metrics not defined in Metadata are filtered-out in handleSimpleDataTable().

MultiSites Plugin Report Metrics are defined in plugins/MultiSites/API.php#L447 :
Ecommerce Orders & Revenue metrics are returned without checking if the Piwik instance has e-commerce enabled.

After reading the second side of this issue, it should become clear, in the context of scheduled reports, that MultiSites.getReportMetadata($notification) can not leverage the value of $notification[$idSites] to determine if e-commerce metrics should be included or excluded in metadata.

2) A scheduled report is necessarily tied to a Site even though it features a multi-site report

The scheduled report plugin was initially developed for mono-site reporting.

A scheduled report is therefore always created for a specific site (ie. the report table has an idsite field).

Later developments included the MultiSites plugin report. The issue described here is not the first one caused by this mismatch.

Scheduled reports are generated using Piwik_API_API::getInstance()->getProcessedReport() by supplying the site identifier the report was created for.

The site identifier is then carried-on all the way to each getReportMetadata() plugin method such as MultiSites.getReportMetadata($notification). In effect :

$notification[$idSites] = site identifier the report was created for

Event though a scheduled report can be created on a non-ecommerce site, the MultiSites report should include e-commerce metrics if the user has permissions to see e-commerce sites.

Therefore, $notification[can not be used in https://github.com/piwik/piwik/blob/master/plugins/MultiSites/MultiSites.php#L41 MultiSites.getReportMetadata($notification) to conditionally include/exclude e-commerce metrics.


Solutions

The currently implemented workaround is to always include e-commerce metrics.

An alternate workaround would be to include e-commerce metrics only if the Piwik instance has at least one e-commerce site.

@julienmoumne
Copy link
Member Author

typo

@mattab
Copy link
Member

mattab commented Mar 11, 2013

An alternate workaround would be to include e-commerce metrics only if the Piwik instance has at least one e-commerce site.

This would be a great workaround indeed!

@julienmoumne julienmoumne added this to the 2.x - The Great Piwik 2.x Backlog milestone Jul 8, 2014
@mattab mattab modified the milestones: Long term, Mid term Dec 5, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Task Indicates an issue is neither a feature nor a bug and it's purely a "technical" change.
Projects
None yet
Development

No branches or pull requests

2 participants