Retired Documentation:  You are using the documentation for version 1.7.3 which was retired in 2013. Go here for the latest version documentation or check here for your available upgrades to the latest version.

Entry "Views" Tracking Tag

ExpressionEngine lets you track how many times a weblog entry has been "viewed" on a particular page.  Up to four different instances of the view counter can be used (each on a different page), enabling you to track different aspects of an entry independently. For example you can use view counter "one" to track views on your comments page and view counter "two" to track views on your permalink page.

Note:  The view tracking counter works in conjunction with the {exp:weblog:entries} tag.  Although you can show the number of views in any instance of your weblog entries tag, the counter will only increment on pages that show a single-entry pages. Single entry pages are ones that show only a single entry, specified dynamically by the ID number or URL Title in the URL, such as comment or permalink pages.

Also Note:  If you have page caching enabled this feature will not work.

Tracking Views

The view tracking feature must be enabled in a specific instance of the {exp:weblog:entries} tag using the track_views parameter.  Within the track_views parameter you will indicate which one of the four "instances" of the view counter you would like to use, like this:

track_views="one"
track_views="two"
track_views="three"
track_views="four"

Here is an example of the weblog entries tag in which the parameter is enabling a view counter:

{exp:weblog:entries weblog="news" limit="1" track_views="one"}

<h3>{title}</h3>

{body}

<div class="date">Posted on {entry_date format="%M %d, %Y"}</div>

{/exp:weblog:entries}

Displaying Views

Each of the above four track_views parameters corresponds to these variables, which can be shown within any instance of a {exp:weblog:entries} tag:

{view_count_one}
{view_count_two}
{view_count_three}
{view_count_four}

Here is an example of the weblog entries tag showing the number of views:

{exp:weblog:entries weblog="news" limit="15"}

<h3>{title}</h3>

{body}

<div class="date">Posted on {entry_date format="%M %d, %Y"}</div>

This entry has been viewed {view_count_one} times.

{/exp:weblog:entries}

Top of Page