With the Data Export API you can develop client applications to retrieve data from the CardioLog reporting engine, and refine the results of the request using query parameters. This allows for even more flexibility and customization than the CardioLog UI, giving you a great deal of freedom over how to design, filter and display your reports. You can also brand your data with your organization's logos and themes to fully own and identify it.
The CardioLog reporting engine generates reports in XML format and as chart images.
Use the Reports API Helper to generate a URL that can be embedded in a client application. When this URL is requested, the report will be generated based on the selected parameters.
- Browse to: http://<cardiolog_server>:<port>/CardioLog/CLReport/ReportsAPIHelper.aspx
- Select a Report.
- Select the report parameters - Date Range, Time Interval, Website Item, Users and Groups
- Check Generate Chart Image to create an image and set its Width and Height (pixels).
- Click Get URL to generate the report URL
- Click Generate Report to generate the report.
- Click Show Advanced Options and Get Report Preferences to modify report preferences.
The CardioLog Report XML Schema
CardioLog report XML files contain both a preferences section (prefs node) and a data section (data node).
Chart
The chart's x-axis values are displayed in the categories node, while y-axis values are displayed in the dataset node. Each chart series is also represented by a dataset node.
Table
The data section for table reports is automatically ready to be implemented in an HTML environment.
<data><![CDATA[<table cache='True'>
<prefs>
<showhelp>false</showhelp>
<showpreferences>false</showpreferences>
<timeframe>36000000000</timeframe>
<timeInterval>36000000000</timeInterval>
<maxrows>10</maxrows>
<mincount>1</mincount>
<reporttype>120</reporttype>
<columns>
<column id="title" title="Title" width="35%" type="SPPage" />
<column id="url" title="Url" width="0" type="hidden" />
<column id="views" title="Views" sorted="true" width="15%" type="number" />
<column id="users" title="Unique Users" sorted="false" width="20%" type="number" />
<column id="avgDuration" title="Duration" sorted="false" width="15%" type="string" />
<column id="exitRate" title="Exit Rate" sorted="false" width="15%" type="number" />
</columns><ctitle>Page Views</ctitle><chartType>static</chartType><adgroup></adgroup><adgroupname></adgroupname><categories></categories><entityId>0:b0426e68-8f34-4eb2-8702-012d5de1c143</entityId><entityName>All</entityName><entityTree>0</entityTree>
</prefs>
<thead>
<td type='SPPage' width='35%' id='title'>Title</td>
<td type='hidden' width='0' id='url'>Url</td>
<td type='number' width='15%' sorted='true' direction='-1' id='views'>Views</td>
<td type='number' width='20%' id='users'>Unique Users</td>
<td type='string' width='15%' id='avgDuration'>Duration</td>
<td type='number' width='15%' id='exitRate'>Exit Rate</td>
</thead>
<tbody from='0' to='10' total='10'>
<tr>
<td>bl_SecondaryNav_Divider.jpg</td>
<td>http://scotland:81/Style Library/Images/bl_SecondaryNav_Divider.jpg</td>
<td>3</td>
<td>3</td>
<td>00:00:04</td>
<td>0%</td>
</tr>
<tr>
<td>Links</td>
<td>http://scotland:81/Lists/Links/AllItems.aspx</td>
<td>3</td>
<td>3</td>
<td>00:00:02</td>
<td>0%</td>
</tr>
<tr>
<td>Workflow Tasks</td>
<td>http://scotland:81/News/WorkflowTasks/AllItems.aspx</td>
<td>3</td>
<td>3</td>
<td>00:00:07</td>
<td>0%</td>
</tr>
<tr>
<td>Total Problems</td>
<td>http://scotland:81/Reports/Lists/Sample Dashboard KPI Definitions/DispForm.aspx?ID=1</td>
<td>3</td>
<td>3</td>
<td>00:00:05</td>
<td>0%</td>
</tr>
</tbody>
<startTime>1/1/0001 12:00:00 AM</startTime><endTime>1/1/0001 12:00:00 AM</endTime><rules>1</rules></table>]]>
</data>
</call>
</report>
</xml>
Meter
The Meter data is displayed in the value node. Below is an example of a Page Views Meter exported using this API.
<xml id="root">
<report>
<call controlId="412" action="get" cached="True">
<controlTitle>Meter</controlTitle><title>Page Views</title>
<prefs>
<prefs><showhelp>false</showhelp><showpreferences>false</showpreferences><timeframe>36000000000</timeframe><timeInterval>36000000000</timeInterval><minvalue>0</minvalue><maxvalue>100</maxvalue><undershoot>0</undershoot><overshoot>100</overshoot><ctitle>Page Views</ctitle><chartType>static</chartType><adgroup></adgroup><adgroupname></adgroupname><categories></categories><entityId>0:b0426e68-8f34-4eb2-8702-012d5de1c143</entityId><entityName>All</entityName><entityTree>0</entityTree></prefs>
</prefs>
falsefalse3600000000036000000000101120Page Viewsstatic0:b0426e68-8f34-4eb2-8702-012d5de1c143All0 Title Url Views Unique Users Duration Exit Rate bl_SecondaryNav_Divider.jpg http://scotland:81/Style Library/Images/bl_SecondaryNav_Divider.jpg 3 3 00:00:04 0% Links http://scotland:81/Lists/Links/AllItems.aspx 3 3 00:00:02 0% Workflow Tasks http://scotland:81/News/WorkflowTasks/AllItems.aspx 3 3 00:00:07 0% Total Problems http://scotland:81/Reports/Lists/Sample Dashboard KPI Definitions/DispForm.aspx?ID=1 3 3 00:00:05 0% 1/1/0001 12:00:00 AM1/1/0001 12:00:00 AM1]]>
</data>
</call>
</report>
</xml>
Examples:
How to add values to the chart image:
In order to add values to a chart, click on Show Advanced Settings in the Data Export API, and then Get Report Preferences. In the preferences XML, edit the <labels>true</labels> key and set the value to true. Values should now appear in the chart.
How to display the page views meter value:
<script>
function getPageViews() {
- Call the web service http://cardiologservername:port/CardioLog/clreport/reportsapi.aspx" with the parameters "action=xml&controlId=3015&timeframe=77760000000000&urls=&usersAndGroups=&categoryId= Making sure to use your server name and port number.
- Create an XML file from the response and find the <data> node: selectSingleNode("//data").text;
- Find the <value> node value with regex. Example:
var re = new RegExp("(^[^$]*<value>)([^<]*)(<\/value>[^$]*$)", "i");
if (response.match(re)) value = response.replace(re, "$2");
document.getElementById("pageviews").innerHTML = "This Year this site was viewed " + value + " times!";
window.onload = function () {
getPageViews();
}
</script>
<body>
<div id ="pageviews" class="sample"> </div>
</body>
</html>