When it comes to driving an Ecommerce business, knowing the right metrics and access to relevant data is half the battle won! This allows you to take immediate and more importantly, the right action.
This extension provides extensive and targeted reports for the Admin. Which products were viewed the most yesterday, which brand is most popular in a particular geography, which user is a consistent buyer and much more, all the reports a website owner could probably need are a click away!
Elaborate reporting from the following categories are available:
- Financial Analysis - Involves reports around sales, payment methods and shipping etc
- Product Analysis - Insights of product purchase, abandoned cart etc
- Promotional analysis - Reports of promotional costs etc are available.
- Search Analysis - Search details reports.
- User Analysis - Includes elaborate user analysis.
Other features include :
- Search and Filter
- Save reports in various formats.
- Refresh reports
- Reset report
- Remove pagination or change pagination count.
- Add spree_admin_insights to your Gemfile:
gem 'spree_events_tracker'
gem 'spree_admin_insights'
- Bundle your dependencies and run the installation generator:
bundle
bundle exec rails g spree_events_tracker:install # Ensure event tracker files are installed
bundle exec rails g spree_admin_insights:install
- Restart your server
Once installed it will automatically starts all data loging and statistical analysis and provides you a user friendly graphical representation of reports. This extension also allows you to download the reports in multiple formats. For more detailed usage please see this blog.
To access these reports goto admin section and click on 'Insights' section in the vertical menu bar.
Create a class that inherits from Spree::Report
and define a report_query
method. If the report is to be paginated. it should define also define a method called paginated
and set it to return true
alongwith defining paginated_report_query
and record_count_query
. the _query
methods should return objects that respond to to_sql
which returns sql string for reporting query.
All reports need to define the following constants:
SORTABLE_ATTRIBUTES
: Other attributes based on which reports can be sorted.DEFAULT_SORTABLE_ATTRIBUTE
: The attribute which is used by default to sort the report results.HEADERS
: The static header fields for report. Note time based fields are automatically added. Any field not declared here but available in observation will be ignored while displaying the report.SEARCH_ATTRIBUTES
: A hash containing the attributes and their name on frontend based on which report result can be filtered.
Additionally they need to define two nested classes. Result
and Result::Observation
.
Result
class can inherit from Spree::Report::Result
if it is a basic report or from Spree::Report::TimedResult
if the result can be time scaled(i.e. changing reporting period changes the scale of report).
Similarly Observation class needs to inherit either from Spree::Report::Observation
or Spree::Report::TimedObservation
. It defines a macro call observation_fields
which can be passed an array or hash with default values of fields which form one report item. Create a method of same name in Observation class for virtual fields which are not returned by queries. ie. average or for formatting db results.
TimedResult
has 2 lifecycle methods which can be overriden for customizing the report output.
build_empty_observations
: Generates empty observations which are later filled with datapoints returned by report query.populate_observations
: Fill the empty observations with data returned via query.
TimedObservation
defines a describes? method which can be overriden to change where the query results gets copied to.
You can add charts to reports by calling charts
with a list of classes representing the chart. Each chart implementing class gets the results in it's initializer and need to implement to_h method returning the json representation of chart.
Finally, register the report in initializer solidus_admin_insights.rb
in its appropriate category or make a new category to make it available in admin dashboard.
First bundle your dependencies, then run rake
. rake
will default to building the dummy app if it does not exist, then it will run specs. The dummy app can be regenerated by using rake test_app
.
bundle
bundle exec rspec spec
Copyright (c) 2017 vinsol.com, released under the New MIT License