Piwik\Plugins\Live\API::getVisitorProfile PHP Method

getVisitorProfile() public method

Returns an array describing a visitor using her last visits (uses a maximum of 100).
public getVisitorProfile ( integer $idSite, boolean | false | string $visitorId = false, boolean | false | string $segment = false, boolean | false | integer $limitVisits = false ) : array
$idSite integer Site ID
$visitorId boolean | false | string The ID of the visitor whose profile to retrieve.
$segment boolean | false | string
$limitVisits boolean | false | integer
return array
    public function getVisitorProfile($idSite, $visitorId = false, $segment = false, $limitVisits = false)
    {
        Piwik::checkUserHasViewAccess($idSite);
        if ($limitVisits === false) {
            $limitVisits = VisitorProfile::VISITOR_PROFILE_MAX_VISITS_TO_SHOW;
        } else {
            $limitVisits = (int) $limitVisits;
        }
        if ($visitorId === false) {
            $visitorId = $this->getMostRecentVisitorId($idSite, $segment);
        }
        $newSegment = ($segment === false ? '' : $segment . ';') . 'visitorId==' . $visitorId;
        $visits = $this->loadLastVisitorDetailsFromDatabase($idSite, $period = false, $date = false, $newSegment, $offset = 0, $limit = self::VISITOR_PROFILE_MAX_VISITS_TO_AGGREGATE);
        $this->addFilterToCleanVisitors($visits, $idSite, $flat = false, $doNotFetchActions = false, $filterNow = true);
        if ($visits->getRowsCount() == 0) {
            return array();
        }
        $profile = new VisitorProfile($idSite);
        $result = $profile->makeVisitorProfile($visits, $visitorId, $segment, $limitVisits);
        /**
         * Triggered in the Live.getVisitorProfile API method. Plugins can use this event
         * to discover and add extra data to visitor profiles.
         *
         * For example, if an email address is found in a custom variable, a plugin could load the
         * gravatar for the email and add it to the visitor profile, causing it to display in the
         * visitor profile popup.
         *
         * The following visitor profile elements can be set to augment the visitor profile popup:
         *
         * - **visitorAvatar**: A URL to an image to display in the top left corner of the popup.
         * - **visitorDescription**: Text to be used as the tooltip of the avatar image.
         *
         * @param array &$visitorProfile The unaugmented visitor profile info.
         */
        Piwik::postEvent('Live.getExtraVisitorDetails', array(&$result));
        return $result;
    }