Hi there! New hack is coming. Today we are going to show you how to see real time online users statistic on your WordPress website.
The best and fastest workaround is a plugin. You can use WP-UserOnline plugin. It allows you to see full statistics about your site visitors.
As usual we will start with the plugin installation. Download WP-UserOnline plugin from wordpress.org.
Navigate to Plugins > Add New page in your WordPress admin panel. Browse plugin file you downloaded. Do not forget to activate plugin after upload.
After plugin is activated, we can change default plugin settings. Open Settings > UserOnline page in your site backoffice.
You will see general plugin settings reflected here. The first section is UserOnline options:
[mfc_lightbox]- Time out. How long until it will remove the user from the database (in seconds).
- UserOnline URL. URL To UserOnline Page. Copy this link you will need it further during statistic page creation.
- Link user names? option. You can link user names to their author page here.
- Naming Conventions lets you to set up default static data titles.
The plugin has several templates available:
[mfc_lightbox]- User(s) online.
- User(s) Browsing Site.
- User(s) Browsing Page.
Here you can modify UserOnline pages layout and content.
Now we can proceed to the next step. You can add user online counter to our site. There are several ways to do this:
- Using widget:
- Visit Appearance > Widgets page in your back-end.
- Locate widget titled UserOnline.
This widget has several statistics available:- Users online count;
- Users browsing current page;
- Users browsing site;
- Users online count & users browsing current page;
- Users online count & users browsing site.
- Place widget to position you wish your users statistics to appear. The result will be as follows:
- Adding it to the page:
- Visit Pages > All Pages section in your admin panel to add statistic page.
- Click Add New at the top left corner to add new page.
- Enter your page title. And add following shortcode to the page content field:
[page_useronline]
- The next step will be page permalink change. Please, locate Permalink section under the page title field. Click Edit button to change the permalink. Remember, we UserOnline URL field on the plugin settings page? Page permalinks was /useronline there. Please, check your newly created page permalink to /useronline .
- Click Publish to save the changes. Now if you what your page to be visible from your site frontend , you can add it to the menu under Appearance > Menus page in your backend. Or leave it as it is, to view the page you can click link under the page title in your admin panel.
From screenshot above you can see that 2 guests are viewing site at this moment. You can see page they visit and time when they opened your site.
- Using php code:
- WP-UserOnline plugin creators recommend adding php code to the theme sidebar.php file.
- You can locate that file in wp-content/themes/themeXXXXX (XXXXX is theme number) directory on your server.
- The code you need to add is:
<?php if (function_exists('users_online')): ?> <p>Users online: <div id="useronline-count"> <?php users_online(); ?> </div></p> <?php endif; ?>
- Once you add this code a field with site visitors statistic will appear on your site.
That is it! You know how to add user static to your site now and find out who is online.
More hacks are coming soon 😉
[mc4wp_form id="74928"]