Advertisement:

Author Topic: how to get Site Visitors Count (Hit Count)  (Read 26516 times)

gstar

  • Full Member
  • ***
  • Posts: 153
Re: how to get Site Visitors Count (Hit Count)
« Reply #15 on: May 12, 2012, 03:05:07 am »
I'd like to see something like:

# of ads posted today
# of total ads

Integrated nicely into the header... Anyone?

Jesse

  • Hero Member
  • *****
  • Posts: 631
  • Out of my mind, back in 5 minutes
Re: how to get Site Visitors Count (Hit Count)
« Reply #16 on: May 12, 2012, 04:24:08 am »
gstar:

There are a few different helper functions that may be of use to you. It will be up to you to decide where and on what pages you display them:

osc_total_active_items() - Gets total number of active items
osc_total_items() - Gets total number of all items
osc_total_active_items_today() - Gets total number of active items today
osc_total_items_today() - Gets total number of all items today



Evelyne:

You can place the code on the two page you specifically mentioned (main.php and item.php pages). You can place the code anywhere on the page you wish for it to display. Exactly where that is is up to you. When in doubt, just use trial-and-error. Insert the code somewhere, look at the results. If you don't like it or it causes an error, just change it again, until you're happy with it. That is a GREAT way to learn, really.  ;)

Evelyne

  • Full Member
  • ***
  • Posts: 134
Re: how to get Site Visitors Count (Hit Count)
« Reply #17 on: May 12, 2012, 05:24:14 am »
Evelyne:

You can place the code on the two page you specifically mentioned (main.php and item.php pages). You can place the code anywhere on the page you wish for it to display. Exactly where that is is up to you. When in doubt, just use trial-and-error. Insert the code somewhere, look at the results. If you don't like it or it causes an error, just change it again, until you're happy with it. That is a GREAT way to learn, really.  ;)

Thank you Jesse!  :D

I found a nice place for it on item.php :)
When I had it in a trial folder, I was less afraid of trying new stuff. Now that I moved the installation to the main directory (ie: it's the official website, yay!), I'm really afraid of messing everything...  ::)

But on main page what I really want it a hit counter to the whole site. I mean, one that shows how many times the website has been viewed (sum of all views?) and this code shows views by items, right? Is there a helper for the whole thing?

Jesse

  • Hero Member
  • *****
  • Posts: 631
  • Out of my mind, back in 5 minutes
Re: how to get Site Visitors Count (Hit Count)
« Reply #18 on: May 12, 2012, 06:31:31 am »
I just made up this function, which you can place into the theme folder file called functions.php. This function simply adds-up all item views for all items.

Code: [Select]
    function site_total_views() {
$conn = getConnection();
$results=$conn->osc_dbFetchResults("SELECT i_num_views FROM %st_item_stats", DB_TABLE_PREFIX);

if(count($results)>0){
    $view_count = 0;
    foreach($results as $result){
$view_count += $result['i_num_views']; // Add-up all item views stored in database
    }
}
return $view_count;
    }


Then, you can call this function from anywhere on your website:

Total item views:
Code: [Select]
<?php echo site_total_views(); ?>

Note: since the above code only adds up individual item page views, it does NOT show total view to your site, including any visitors to your "main" page, search pages, or any other non-item page.
« Last Edit: May 12, 2012, 06:47:26 am by Jesse »

Evelyne

  • Full Member
  • ***
  • Posts: 134
Re: how to get Site Visitors Count (Hit Count)
« Reply #19 on: May 12, 2012, 07:04:00 am »
THANK YOU Jesse!!!

It works and it's perfect!!!  ;D

Jesse

  • Hero Member
  • *****
  • Posts: 631
  • Out of my mind, back in 5 minutes
Re: how to get Site Visitors Count (Hit Count)
« Reply #20 on: May 12, 2012, 07:16:43 am »
I don't know about perfect, but glad it works!!!  ;D  You're welcome!

Jesse

  • Hero Member
  • *****
  • Posts: 631
  • Out of my mind, back in 5 minutes
Re: how to get Site Visitors Count (Hit Count)
« Reply #21 on: May 12, 2012, 08:41:38 am »
I just came across this function for showing item counts, it may be helpful to others. I've not even tested it out, so can't provide much more info on it (found within the file Stats.php in oc-includes/osclass/classes).

Code: [Select]
        public function new_items_count($from_date, $date = 'day')
        {
            if($date=='week') {
                $this->conn->select('WEEK(dt_pub_date) as d_date, COUNT(pk_i_id) as num') ;
                $this->conn->groupBy('WEEK(dt_pub_date)') ;
            } else if($date=='month') {
                $this->conn->select('MONTHNAME(dt_pub_date) as d_date, COUNT(pk_i_id) as num') ;
                $this->conn->groupBy('MONTH(dt_pub_date)') ;
            } else {
                $this->conn->select('DATE(dt_pub_date) as d_date, COUNT(pk_i_id) as num') ;
                $this->conn->groupBy('DAY(dt_pub_date)') ;
            }
           
            $this->conn->from(DB_TABLE_PREFIX."t_item") ;
            $this->conn->where("dt_pub_date > '$from_date'") ;
            $this->conn->orderBy('dt_pub_date', 'DESC') ;
           
            $result = $this->conn->get() ;
            return $result->result() ;
        }

gstar

  • Full Member
  • ***
  • Posts: 153
Re: how to get Site Visitors Count (Hit Count)
« Reply #22 on: May 12, 2012, 11:02:48 am »
gstar:

There are a few different helper functions that may be of use to you. It will be up to you to decide where and on what pages you display them:

osc_total_active_items() - Gets total number of active items
osc_total_items() - Gets total number of all items
osc_total_active_items_today() - Gets total number of active items today
osc_total_items_today() - Gets total number of all items today


Wow cool... Thanks a lot!!!

Jesse

  • Hero Member
  • *****
  • Posts: 631
  • Out of my mind, back in 5 minutes
Re: how to get Site Visitors Count (Hit Count)
« Reply #23 on: May 12, 2012, 11:32:38 am »
No prob! Be sure to check out the many, many other "Helper" functions here.... http://doc.osclass.org/Helpers

gstar

  • Full Member
  • ***
  • Posts: 153
Re: how to get Site Visitors Count (Hit Count)
« Reply #24 on: May 12, 2012, 12:56:01 pm »
No prob! Be sure to check out the many, many other "Helper" functions here.... http://doc.osclass.org/Helpers

Thank you Jesse I didn't see that one yet.. Will check it out :)

asimshaz

  • Sr. Member
  • ****
  • Posts: 311
  • 01tec
Re: how to get Site Visitors Count (Hit Count)
« Reply #25 on: May 12, 2012, 09:53:52 pm »
nice job ;)

srinivas

  • Newbie
  • *
  • Posts: 1
Re: how to get Site Visitors Count (Hit Count)
« Reply #26 on: November 22, 2012, 07:38:19 am »
Hi,

   There are so many methods in helper class hItems.php.
      I am using <?php echo 'No. of view are :'.ItemStats::newInstance()->getViews(osc_item_id()); ?>') this method for getting Number of views hit by the user.But my case is i want to get the views count specific to day wise to the specific item.

for example:

  [d_date] => 2012-11-20 [views] => 0
  [d_date] => 2012-11-21[views] => 4
  [d_date] => 2012-11-22 [views] => 7

Thanks,
Srinivas.

rainilson

  • Newbie
  • *
  • Posts: 37
Re: how to get Site Visitors Count (Hit Count)
« Reply #27 on: July 02, 2018, 11:03:42 pm »
dear friends, I wanted an accountant, where to show me on the admin page, how many people entered my site, I do not want them to show how many ads they will see, but how many people will enter my site. Can someone help me please ?