Download EE 2 Docs Download EE 1 Docs
ExpressionEngine

2.9.2 User Guide

Statistics

Introduction

ExpressionEngine includes a Statistics Module that tracks a number of system statistics. The basic tag consists of a tag pair:

{exp:stats}
        statistics content
{/exp:stats}

Parameters

site=

site="default_site"

This parameter can be used to restrict the statistics reporting to specific sites when using the Multiple Site Manager. You can use the pipe character to separate multiple sites:

site="default_site|boston|new_york"

Or you can add the word “not” (followed by a space) to exclude sites:

site="not chicago|los_angeles"

channel=

channel="default_site"

This parameter can be used to restrict the statistics reporting to specific channels. Note that not all of the statistics variables are affected by this parameter; those that are affected will be noted. Additionally, you can use the pipe character to separate multiple channels:

channel="default_site|sports|news"

Or you can add the word “not” (followed by a space) to exclude channels:

channel="not channel5|channel6"

Here is an example of the tag with the parameter in use:

{exp:stats channel="news|sports"}
        statistics content
{/exp:stats}

Variables

last_comment_date

{last_comment_date format="%m/%d/%Y %h:%i %a"}

The date of the most recent comment. This variable can be affected by the channel= parameter. See Date Variable Formatting for more information.

last_entry_date

{last_entry_date format="%m/%d/%Y %h:%i %a"}

The date of the most recent entry. This variable can be affected by the channel= parameter. See Date Variable Formatting for more information.

last_visitor_date

{last_visitor_date format="%m/%d/%Y %h:%i %a"}

The date of most most recent visitor to the site. See Date Variable Formatting for more information.

most_visitor_date

{most_visitor_date format="%m/%d/%Y %h:%i %a"}

The date on which the most visitors were ever viewing the site at the same time. See Date Variable Formatting for more information.

most_visitors

{most_visitors}

The greatest number of visitors ever online at the same time. This includes members, guests/non-members, and anonymous users.

total_anon

{total_anon}

The total number of people currently online who have chosen to be “anonymous” and not have their name revealed.

total_comments

{total_comments}

The combined total number of comments for all entries. This variable can be affected by the channel= parameter.

total_entries

{total_entries}

The total number of entries in the database. This variable can be affected by the channel= parameter.

total_guests

{total_guests}

The total number of people currently using the system that are not logged in as members.

total_logged_in

{total_logged_in}

The total number of members that are currently logged in to the system.

total_members

{total_members}

The total number of registered members.

Member Names

The member_names variable pair allows you to show the currently logged in users:

{member_names}
        <a href="{member_path='member/index'}">{name}</a><br>
{/member_names}

The {member_path=’‘} variable allows you to create a link that points to the member’s profile page. The example above illustrates how it can be used.

The member_names variable pair can also be used as a conditional:

{if member_names}
        {member_names}
                {name}<br>
        {/member_names}
{/if}

There is one optional parameter that goes in the opening {member_names} variable that allows “backspacing”:

{member_names backspace="5"}

Backspacing removes characters from the last iteration of the loop. For example, if you put a <br> tag between each member name you’ll have this layout:

Joe<br>
Fred<br>
Sallie<br>

You might, however, not want the <br> tag after the final item. By adding backspacing you can remove it. Simply count the number of characters and spaces in the item you want to remove and add it to the tag. A <br> tag has 5 characters including the newline character, so you would do this:

{member_names backspace="5"}
        <a href="{member_path='member/index'}">{name}</a><br>
{/member_names}

That will produce code like this:

Joe<br>
Fred<br>
Sallie

User Contributed Notes

Posted by: Bjørn Børresen on 18 February 2015 8:33am
Bjørn Børresen's avatar

Note that this addon will not work until you enable “Online User Tracking?” under “Tracking Preferences” in the control panel. You’ll just get empty strings for {total_members} etc. until you do so.

You must have an EllisLab product license and have at least 50 posts to the community forums to contribute notes to the User Guide