Report layouts
Laika can show three different types of report layouts when browsing to a given menu item:
- Simple report
- Combined report
- Custom report
This guide will show you what to enter in the nav_items
table for the report_layout
column to get a particular report type to display.
Simple reports show data in a chart for a given metric, one chart per site in your environment. If you have three sites listed, you will get three charts.
- Only sites with
showData = 1
will be displayed. - The charts display in ascending order sorted based on the site
id
.
To display a simple report, create a menu item with the following as report_layout
:
doReport("x");
Where x
is the metric id
you wish to display data for.
- Be sure to add the ending semicolon.
Combined reports show multiple metrics in a single chart, one chart per site in your environment.
- You can combine up to 7 metrics in a single chart.
- Only sites with
showData = 1
will be displayed. - The charts display in ascending order sorted based on the site
id
.
To display a combined report, create a menu item with the following as report_layout
:
doReport("x,y,z");
Where x,y,z
is a comma-separated list (with no spaces after the commas, like this: 1,2,7,13
) of metrics to display.
- Be sure to add the ending semicolon.
You can manually provide HTML layout and pass direct PHP functions to Laika in order to generate custom report layouts.
Start by creating a PHP file in the tenant folder for your domain. For example, /pack-members/domain/report-14.php
for a custom report on menu item 14
. Within that file, enter the following:
<div class="row">
<div class="col-md-12">
<?php
$reportData = getData( "1", NULL, TRUE, TRUE );
echo writeReport( $reportData, "<a href=\"/?r=1\">Overall traffic</a>", "The total number of page views to each website.", TRUE );
?>
</div>
</div>
<div class="row">
<div class="col-md-6">
<?php
$reportData = getData( "2" );
echo writeReport( $reportData, "<a href=\"/?r=2\">New sessions</a>", "Number of new visits.", TRUE );
?>
</div>
<div class="col-md-6">
<?php
$reportData = getData( "3", NULL, TRUE, TRUE );
echo writeReport( $reportData, "<a href=\"/?r=3\">Session duration</a>", "Average time spent on site.", TRUE );
?>
</div>
</div>
In this example, the report will have two rows. The first row will contain a single chart in a full-width column will display, followed by a row with two half-width charts directly underneath it. Also, custom chart titles and captions are provided.
To display a custom report, create a menu item with the following as report_layout
:
showReport("report-14.php");
Laika will look for report-14.php
in the domain's pack-member folder and, if it exists, will display the custom report as you have entered it.
- You can use any filename for the custom report. Using the menu item's
id
field in the filename helps make it clear where the custom report will be displayed.