Ask your WordPress questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

Display a list of non-logged in visitors who have viewed a post WordPress

  • REFUNDED

I want to log and display all non-logged in visitors who view my posts. But I don't want them to log in. I want all the visitors displayed by some way that can give each visitor a unique name e.g. IP, cookie?

Answers (5)

2021-01-22

Francisco Javier Carazo Gil answers:

You cannot identify an user using their IP because this can be shared between thousend who use CG-NAT for example.

About cookies... what are you going to write/read in this cookie? Some kind of random value unique for each user maybe.

Why don't you use some kind of analytics service?


pjeaje comments:

"Some kind of random value unique for each user maybe"... Yes that would be ok


pjeaje comments:

Would there be a way for a pop up box to appear the first time and ask the visitor for their name, and use their name as part of the unique identifier?


Francisco Javier Carazo Gil comments:

Here in Europe you have to take care about privacy... you should first do some kind of "ask if they consent to be tracked by their names".


pjeaje comments:

I've got the privacy situation sorted


Francisco Javier Carazo Gil comments:

You can hook into wp_footer, for example, prepare the dialog and:
1) save a cookie to check if it is a returning visitor
2) save the name using ajax if this is a new one


pjeaje comments:

Thanks do you some code I can test?


Francisco Javier Carazo Gil comments:

Sorry but this is not so little project...

If you code what I told you, you have it done.


pjeaje comments:

I can't code. That's why we use this website. Thanks.


Francisco Javier Carazo Gil comments:

Sorry but $10 is not enough. In this case in our company it would take some hundred of euros.

Anyway, you have the idea and how to get it done.


pjeaje comments:

This is not a private business model.

2021-01-22

Navjot Singh answers:

Do consider the privacy implications of trying to identify non-logged visitors especially in today's world. Google or Matomo Analytics in itself should be sufficient to track user behaviour (it comes with ample features) without the need to maintain a user list where you need to place a tracking cookie.


pjeaje comments:

All the visitors need to be displayed on the post.


Navjot Singh comments:

I don't know if it helps but you can always make the site as register to view and then you can add as many custom fields or information that your members can fill. It will also be less intrusive.

And displaying those visitors on the post shouldn't be an issue as well since they are all logged-in visitors.


pjeaje comments:

Thanks, but as per my question, "... I don't want them to log in"

2021-01-22

Monit Jadhav answers:

I found two such plugins that can help you with some tweaks

https://wordpress.org/plugins/page-visit-counter/

https://wordpress.org/plugins/wps-visitor-counter/

The page visit counter plugin gets more data from the visit so may be you can use that data on the frontend.

See the fields below

id
page_id
user_id
user_role
date
lastdate
ipaddress
country
browser_full_name
browser_short_name
browser_version
os
http_referer
type

I want all the visitors displayed by some way that can give each visitor a unique name e.g. IP, cookie?

I don't Know how will you get their names? By default the users gets a user_role as guest which you can change

Inside Page visit Counter go to public directory then class-page-visit-counter-public.php

page-visit-counter\public\class-page-visit-counter-public.php

Line number 230-236

if ( $user_id ) {
$user = get_userdata( $user_id );
$user_roles_arr = $user->roles;
$user_role = $user_roles_arr[0];
} else {
$user_role = 'guest';
}

Here you can generate random names assign to a variable and replace $user_role with that variable.

You can create a array randomizer of random names see the link below

https://stackoverflow.com/questions/4233407/get-random-item-from-array

Hope this can give the guests unique names and you can query the database table "wp_page_visit_history"


pjeaje comments:

Unfortunately I don't know how to code. I need all the the unique identifiers (cookies?) of each guest that has visited the post, and that list displayed on the post.

2021-01-23

Bob answers:

This plugin has widget which you can put in footer widget of your theme.

https://wordpress.org/plugins/wp-statistics/

It has bunch of options to show users.


pjeaje comments:

Thanks but it doesn't do what I want to do as per my question.

2021-01-23

pjeaje answers:

I think all I need is each visitor is given a permanent cookie, and that cookie is stored in the post's meta. If there could be a pop up to get the visitor to name their own cookie then that would be ideal.


pjeaje comments:

This may help. This does exactly what I want to do but for logged in users, except I want it to be done with logged out visitors with their own cookie...
https://wordpress.stackexchange.com/questions/378874/display-a-list-of-users-who-have-viewed-the-post-you-are-viewing/378938