Jquery | $ is not defined - Solving JQuery Conflict

Author - Kiran Preet
26.10.2017
|
0 Comments
|

Piwik analytics is a open source analytic platform. Piwik provides APIs to manipulate and fetch analytics data and one can also create their custom APIs for same purpose. There are many APIs available in PIWIK but here I will explain Module Live API.

The Live API lets you access complete visit level information about your visitors. there are four main methods available in this API :

– Live.getCounters (idSite, lastMinutes, segment = ”, showColumns = ‘Array’, hideColumns = ‘Array’)

“getCounters” is used to return a simple counter: visits, number of actions, number of converted visits, in the last N minutes.

– Live.getLastVisitsDetails (idSite, period = ”, date = ”, segment = ”, countVisitorsToFetch = ”, minTimestamp = ”, flat = ”, doNotFetchActions = ”)

The method “getLastVisitsDetails” will return extensive data for each visit, which includes: server time, visitId, visitorId, visitorType (new or returning), number of pages, list of all pages (and events), time spent on pages and much more.

– Live.getVisitorProfile (idSite, visitorId = ”, segment = ”, limitVisits = ”)

The method “getVisitorProfile” will return latest visitors data for the last visit like country, continent, first visit, last visit etc.

– Live.getMostRecentVisitorId (idSite, segment = ”)

The method “getMostRecentVisitorId” as name suggests, will return the PIWIK visitor id for most recent user. example: {“value” :”536af8dd929cfc82″}.

We will take a PHP example for “getLastVisitsDetails” API and will explain it to get clear view of the uses:

<?php

$url = "http://PiwikURL/";

$url .= "?module=API&method=Live.getLastVisitsDetails";

$url .= "&idSite=1&period=range&date=2017-08-28,today";

$url .= "&format=XML";

$url .= "&token_auth=annoymous";

$url .= "&segment=userId==1;customVariableValue1==pageName");

$fetched = file_get_contents($url);

$content = unserialize($fetched);

// case error

if (!$content) {

// print("Error, content fetched = " . $content);

}

// case error

if (!$content) {

// print("Error, content fetched = " . $content);

}

print("<h1>Live data for the specified date range: </h1>\n");

foreach ($content as $row) {

    //  get your data here;

}

You can provide output format for the request as &format= json/XML/PHP etc.

Live API can be used with Segments. Segments are like WHERE clause and can be used to filter the data. Several Segments can be combined together with AND and OR logic. “;” is used for AND operator and “,” is used for OR operator.

Data can be fetched for a particular date as well as for date range. Here we are using the date range like period=range&date=startDate,endDate. The period you request the statistics for can be any of: day, week, month, year or range. All reports are returned for the dates based on the website’s time zone.

Webner Solutions is a Software Development company focused on developing Insurance Agency Management Systems, Learning Management Systems and Salesforce apps. Contact us at dev@webners.com for your Insurance, eLearning and Salesforce applications.

Leave a Reply

Your email address will not be published. Required fields are marked *