3

Say I have a Channel calls "Products" that contain individual product information. Is there a way to set up EE so it can keep count of the number of times the product was viewed in the front end?

2 Answers 2

3

ExpressionEngine has 'view tracking' functionality, built into the system, that can be used. Be aware that it can cause a performance hit for heavy traffic sites.

If your site receives a lot of traffic, you may wish to turn off (disable) EE's tracking capabilities and use a third party add-on, such as Solspace's Tracker. Tracker has some intelligence involved, and tries to exclude traffic from bots and search engines.

Here's sample code for using EE's internal view_count

{exp:channel:entries channel="books" orderby="date" sort="desc" limit="1" track_views="one" disable="categories|category_fields|member_data|pagination|trackbacks"}


<h2 class="title">{title}</h2>
<p><b>Author</b>: {book_author}
<br /><b>Publisher</b>: {book_publisher}</p>

{book_review}

{/exp:channel:entries}

Just adding the track_views="one" to a single article/view page, will start the view count process. To display, the number of views or to just sort by popularity, you would then use view_count.

If you are using the Tracker Module, you would add the view count like so

{exp:channel:entries channel="books" orderby="date" sort="desc" limit="1" disable="categories|category_fields|member_data|pagination|trackbacks"}

{exp:tracker:track channel="books" entry_id="{entry_id}"}

<h2 class="title">{title}</h2>
<p><b>Author</b>: {book_author}
<br /><b>Publisher</b>: {book_publisher}</p>

{book_review}

{/exp:channel:entries}

Tracker, also provides an interface for looking at the data internally in the control panel.

Tracker: Channel View

This can be beneficial, when you want to see popularity, but don't want to display it on the front-end of the site.

Either way, don't forget to set-up one or two Google Analytic Dashboards. Dashboard Junkies create some of my favorite GA Dashboards. See this one for tracking sales, Dashboard 11: Sales Cockpit

Dashboard: Sales Cockpit

You can add them to your Google Analytics account, to dive into your data, faster. As well as customize them to better suit your website. You probably want to add some data funnels as well, so you can see, if and when users drop out of the sales process.

6
  • Tracker seems to be closer to what I was looking for. I didn't actually want to show on the front end the number of views of a Channel entry. I wanted to see this information in the CP. As for the Google Analytic Dashboard - is that something that would be incorporated in the CP? Commented Feb 2, 2013 at 7:02
  • Not the Dashboard itself, but there is an add-on called CP Analytics [devot-ee.com/add-ons/cp-analytics], that will bring over basic data from Google Analytics (GA), and potentially encourage people to visit GA more frequently. Or could be set to mail a report (PDF) weekly, monthly, or quarterly. Commented Feb 2, 2013 at 7:20
  • How much of a performance hit would the standard entry tracking cause? And what do you think classes as a heavy traffic site? Just curious, as wasn't aware of that!
    – shorn
    Commented Feb 2, 2013 at 12:34
  • It's probably different site by site. So you should definitely test on your site specifically. But it typically increases the MySQL query queue, as well as the amount of data returned. Most EE MySQL installs are MyISAM which locks the table when updating. When tracking, a table needs to be updated each time the page loads. This can cause a queue for MySQL, which is probably more the issue than the extra data. Read the link for 'Heavy Traffic Sites' above. Commented Feb 2, 2013 at 14:31
  • Someone else may have a better reply for this. I consider high traffic relative to the websites normal load. Many of our clients are on Shared server plans. I expect those sites to be able to handle 3-5 times, the regularly level of traffic, that the site is tested for, regardless if that's 2,000 hits per hour or 10,000 hits per hour. SO we consider high traffic +5x the normal traffic. For example, a client w/normal traffic of ~1,500 hits/hr spiked to 60k hits/hr, a static version of the page and disabling tracking, kept/returned the server running. But some sites handle 60k hits/hr as normal Commented Feb 2, 2013 at 14:40
0

ExpressionEngine does have an Entry “Views” Tracking Tag

However, it's probably better to use something like Google Analytics for this. The problem with counting views from server hits is it will include things like GoogleBot indexing your site, which isn't particularly helpful for telling which page is the most popular. I'm not aware of any plugins which can access the Google Analytics API to return the view count for a particular page, but it's certainly possible, so a plugin may exist, or you could create one.

1
  • This would allow me to display the views on the front end, right? I wanted some way to view this stuff in the CP. Google Analytics is already included on my site, just wanted some dashboard to see such statistics in the CP. Commented Feb 2, 2013 at 6:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.