Hits

Primary Template Tracking Tag - Entries

{exp:hits:count_hits} 

Tag Parameters

item_id="" // ENTRY_ID (REQUIRED) 
type="weblog" // For weblog entries: weblog (REQUIRED) 
parent_id="" // Weblog ID (only if you have direct access to the weblog_id 
weblog="" // Optional weblog short name if you don't have access to weblog_id. 

Note: using parent_id is faster.

Hits Integration Example

{exp:weblog:entries weblog="products"}
    {exp
:hits:count_hits type="weblog" item_id="{entry_id}" parent_id="{weblog_id}"}
    
<h2>{title}</h2>
    
{body}
{
/exp:weblog:entries} 

Alternate Image Counter

{exp:hits:count_hits_image} // Same parameters as previous tag. This is useful for cached pages. 

Image Counter Example

{exp:weblog:entries weblog="products"}
    
<h2>{title}</h2>
     <
img src="{exp:hits:count_hits_image item_id="{entry_id}" parent_id="{weblog_id}" type="weblog"}" />
{/exp:weblog:entries} 

Forums Tracking

A special URL is provided within the Hits Module CP "Settings" to track forum posts. Once installed a dynamic URL will be provided. Place that code in the following template: Thread View Templates > Threads.

Display Entries

{exp:hits:items} 

Display Top Entries Example

<ul>
{exp:hits:items type="weblog" top="today" limit="4" weblog="blog"}
    
<li><a href="/blog/post/{hits:item_url_title}">{hits:item_title}</a></li>
{/exp:hits:items}
</ul

Tag Parameters

type="" // Which type? weblog/forums (REQUIRED) 
top="" // Top what? today/yesterday/week/month/year (REQUIRED) 
limit="" // Default: 10 
parent_id="" // Restrict items to a specific parent, weblog or forums. 
weblog="" // Restrict weblog entries to specific weblog 

Conditionals

{if no_hits} {/if} 

Variables

{hits:item_id} 
{hits:item_title} 
{hits:item_hits} 

Weblog Entries these variables are also available

{hits:item_url_title} 
{hits:item_url} 
{hits:item_weblog} 

Forums these variables are also available

{hits:item_url} 
{hits:item_forum}