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="one" and view_count_one - Why am I struggling??

August 07, 2012 5:39pm

Subscribe [2]
  • #1 / Aug 07, 2012 5:39pm

    a la mode

    168 posts

    I have struggled with this site to get tracking working and I am beyond frustrated. This is an older site (EE 1.6.8 - Build:  20090723) which they will not upgrade. So that is not an option.

    I have the following set to ‘yes’ in

    Admin ›  System Preferences ›  Tracking Preferences :

    Enable Online User Tracking?
    Enable Template Hit Tracking?
    Enable Section Entry View Tracking?
    Enable Referrer Tracking?

    I have a single entry template with this opening tag:

    {exp:weblog:entries weblog="blog_real" limit="1" status="open" url_title="{last_segment}" track_views="one"}

    That is the view template. I am trying to show the top five read posts in a rail element. For that, I am using this:

    {exp:weblog:entries weblog="blog_real" orderby="view_count_one" sort="asc" status="open" limit="5" dynamic="off"}

    Is there something I am missing? I have even tried stripping the code out and doing an “empty” template, but it isn’t writing to the db when I look at the data through the SQL Manager.

    Thanks guys,
    Brian

  • #2 / Aug 08, 2012 2:01pm

    Kevin Smith

    4784 posts

    Hi Brian,

    So the problem is with the first part then, right? EE’s not updating the DB to note how many views the first weblog entries tag is getting, correct?

    I know they don’t want to update to EE 2 yet, but can you convince them to update to the latest EE 1? The version you’re running is over 3 years old right now, and I dare say this behavior might be a bug that’s been fixed in the time since.

    Could you turn on SQL debugging to see if you can find the query that tries to update the DB with the view count?

  • #3 / Aug 08, 2012 2:25pm

    Boyink!

    5011 posts

    I suspect it’s because the single-entry tag isn’t running dynamically.

  • #4 / Aug 08, 2012 4:10pm

    a la mode

    168 posts

    Thanks guys. I have tracked down the issue to this:

    This site was built without using the categories and templates/groups in a way I would prefer. So there is a template in a group that does nothing more than redirect the user to another location or embed a proper page based off of the URI. That template looks like this:

    {if "{segment_3}" == "feed"}
        {redirect="blog_real/feed"}
    {if:elseif "{segment_3}" == "view"}
        {embed="blog_real/view"}
    {if:else}
        {embed="blog_real/index"}
    {/if}

    From this, the middle embed uses this heading:

    {exp:weblog:entries weblog="blog_real" limit="1" status="open" url_title="{last_segment}" track_views="one"}

    There is a rail on that page which has this:

    {embed="blog_real/most_viewed"}

    Which is nothing more than this:

    {exp:weblog:entries weblog="blog_real" orderby="view_count_one" sort="asc" status="open" limit="5" dynamic="off"}
        <li><a href="http://{title_permalink=group/blog/view}">{title} - {view_count_one}</a></li>
    {/exp:weblog:entries}

    If I don’t use the initial embeds, the counts take. I just don’t know how to achieve the desired effect due to the existing structure without them. Any ideas?

    Thanks in advance all.
    Brian

  • #5 / Aug 09, 2012 10:51am

    Lisa Wess

    20502 posts

    Hi, Brian -

    OK.  So your last segment has the URL title.  Which segment does that tend to be in? If it is not segment 2 or 3, track_views simply won’t track views - it only tracks what it deems to be a single entry page as defined by having the URL title or Entry ID in segment 2 or segment 3.

    However, can you try this hidden config option? relaxed_track_views

    and see if that helps?

  • #6 / Aug 09, 2012 11:09am

    a la mode

    168 posts

    Lisa,

    That did work, however, it now increments by 2 each view now. 

  • #7 / Aug 09, 2012 11:10am

    Lisa Wess

    20502 posts

    Hi, Brian

    Are you using multiple channel entries tag, both showing a single entry? ie: for the title or some such?

    You may have some struggles using this due to the odd setup, I will admit that.  We’re having to relax that feature to be less judicious about what is being counted - but that may come at some cost.

    Does that make sense?

  • #8 / Aug 09, 2012 11:12am

    a la mode

    168 posts

    Lisa,

    It does. I made a quick change and all is working now. Thank you so much!

    Brian

  • #9 / Aug 09, 2012 11:14am

    Lisa Wess

    20502 posts

    Rockin’ Brian!  So glad that helped you out. If anything else comes up, please let us know.  Have a wonderful Thursday!

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

ExpressionEngine News!

#eecms, #events, #releases