ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Track views not working (View count does not increment)

July 25, 2013 3:54am

Subscribe [3]
  • #1 / Jul 25, 2013 3:54am

    srajeev

    6 posts

    Hello all,

    I have been trying to get view_count tag working for me since few weeks now for a website which has a section called trending. I followed almost every other post on this forum, tried various suggestion however I just cant get it to start incrementing the view count. Have enabled tracking in preferences. Any help will be much appreciated.

    My code :

    {exp:channel:entries url_title="<?php echo $url;?>" limit="1"  track_views="one"}
        <div class="fixedTitleWrap" >
         <div class="article-heading">{title}</div>    
      {exp:trunchtml chars="150" inline="..."}{story}{/exp:trunchtml}
            <div class="clear"></div>
     </div>
    {/exp:channel:entries}
    
    <div class="paginationWrap">
    
    <?php if($previous_id!=''){ ?>
    {exp:channel:entries entry_id="<?php echo $previous_id?>" channel="not correspondents"}
     <div class="lhs">
            <span class="arrow prev"></span>
      <span class="articleTitle prevTitle">{title}</span>
            <span class="clear"></span>
            </a>
     </div>
    {/exp:channel:entries}
    <?php } ?>
    
    <?php  if($next_id!=''){ ?>
    {exp:channel:entries entry_id="<?php echo $next_id?>" channel="not correspondents"}
     <div class="rhs">
            <span class="arrow next"></span>
      <span class="articleTitle nextTitle">{title}</span>
            <span class="clear"></span>
            </a>
        </div>
    {/exp:channel:entries}
    <?php } ?>
    
    </div>

    Retrieval code :

    {exp:channel:entries  orderby="view_count_one" dynamic="no"  sort="desc" search:gc_city="=Mumbai" }
     <div class="content"> 
      <div class="heading">{title}</div>
      <div class="view_count">This entry was viewed {view_count_one} times</div>
     </div>
    {/exp:channel:entries}

    The view_count_one reflected in any of the posts is 0.

  • #2 / Jul 25, 2013 6:02am

    srajeev

    6 posts

    Wow, Got it solved 😊

    Was browsing various threads and came across this solution where you just need to add this parameter to your config file and bam! it worked like a charm.

    http://ellislab.com/expressionengine/user-guide/general/hidden_configuration_variables.html#relaxed-track-views

    Thank you for going thru posts. Hope this helps someone.

  • #3 / Nov 08, 2013 9:50am

    Thank you srajeev for posting this. I was having the same problem and this just saved my huge amounts of valuable client time 😊

  • #4 / Apr 03, 2014 11:38am

    This topic has not been visited for awhile, but I wanted to add a comment in case anybody else has an issue with creating a “Trending Articles” list. I am using EE 2.8.1, so I cannot speak to earlier versions.

    1. Add track_views to your channel entries tag where your single article is generated.

    {exp:channel:entries 
     channel="articles" 
     limit="1" 
     disable="member_data|pagination" 
     dynamic="yes" {!-- this is your article display, so dynamic="yes" --}
     status="open" 
     track_views="one" {!-- this will start tracking the article as group "one" you can have up to 4 --}
    }
     {title}
     {!-- whatever other content you're outputting here --}
    {/exp:channel:entries}

    2. Create your trending articles list. You’ll call the tracking group “one” specified above:

    <ul>
    {exp:channel:entries 
     channel="articles" 
     limit="10" 
     orderby="view_count_one" {!-- order by tracking group one --}
     sort="desc" {! -- most viewed at the top --}
     dynamic="no" {!-- must be set to no --}
     disable="categories|category_fields|custom_fields|member_data|pagination" 
    }
     <li>
      <a href="http://{url_title_path=articles}">{title} <span class="count">{view_count_one}</span></a> {!-- note the view_count_one tag here --}
     </li>
    {/exp:channel:entries}
    </ul>

    3. In your System Configuration overrides, make sure that the following configs are set properly. You can access your Configs by going to Admin > System Configuration > Config File Editor. For more info, see: http://ellislab.com/expressionengine/user-guide/general/system_configuration_overrides.html

    a. disable_all_tracking = n
    See: http://ellislab.com/expressionengine/user-guide/general/system_configuration_overrides.html#disable-all-tracking
    b. enable_entry_view_tracking = y
    See: http://ellislab.com/expressionengine/user-guide/general/system_configuration_overrides.html#enable-entry-view-tracking

    After you have this all in place, you should begin to see the views increment in your list every time you visit your article page.

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases