Can i recive a email or count evry time a user hit a certain page on my website
Autor: A. Remus
Visitado 1112,
Seguidores 1,
Compartilhado 0
Hello. Maybe for many of you it seems a silly question / ideea but for me is a really struggle and since most of time i was found help here i decided to ask.
So basicaly what i need is even to recive a email whan a user hit a certain page from my website (so not all the pages) or somehow to count externaly (i know well hitcounters from internet and is not what i need) on a dashboard or something.
Many thanks in advance.
Remus A
Publicado em
I am not sure exactly what you need but here is some suggestions:
Google Analytics: With this tool you can see which pages is "used". You can see from where your users is coming from (countries, cities) and how long they stay on your pages. You can even see in real-time which page is visited and where the user comes from. Also what device is used and the browser.
Google Search console: Here you can see which pages is shown in Google searches and which position. You can see if how many "shows" that resulted in a click for a page.
In both tools you can "design" reports.
https://search.google.com/search-console/about
https://marketingplatform.google.com/about/analytics/
Similar tool for Edge from Microsoft: VStat 2 - visit statistics & website traffic - Microsoft Edge Addons
Screenshot from Google Analytics Real-time view.
@Remus
If you just need to get an e-mail when a user opens a particular page...
you just need to put instructions in PHP that send you the email , the page needs to be .php and not .html
If you search in the net you will find several ideas for doing this....
This is an example of the code you need.
put it, in HTML object.
I see that Claudio has a more direct answer to your question. I thought of the same, but could not see why you should need that without having any information other than your page had been visited.
Maybe you want to see if a visitor is recurring?
This could be done somewhat like this:
<?php
// set your e-mail address first, where you'll receive the notifications - use mail from own domain
$yourEmailAddress = "***";
$emailSubject = "Someone visited Webpage: yourpagename";
$remoteIpAddress = $_SERVER['REMOTE_ADDR'];
$emailContent = "Someone visited your webpage. IP address:".$remoteIpAddress;
// send the message
mail($yourEmailAddress, $emailSubject, $emailContent);
?>
If you don't need the IP, then you should use the answer given by Claudio
@Remus - maybe you could tell some more of what it should be used for.
$yourEmailAddress = "***";
should be
$yourEmailAddress = "user(at)domain(dot)com";
You could also store information in a database. Timestamp and IP. Maybe even some geo-loacation
This will make it possible to make statistic on the page visits. It could be used in combination with the mail-sending.
But why then not use what I suggest in my first post.
Autor
Thank you.
Exactly like you supossed. I need to know if a certain user was visited a certain page. The first part i was solved because on that page only that user have acces. I vill give a try with your ideea. Google analitics unfortunetly even it work and i have on my website do not fullfill my needs.
Thank you. After give a try i will come back.
You can put the following in a html-object on the page you want to monitor.
It will log a line in a txt-file (logfile.txt) The file will be created if not existing. Depending of how many "logs" will be in the file you could download it to your desktop every week/month/year and then delete it on the server. A new file will be started and so on.
The IP and the date (when the page initial is accessed) will be logged. You can style the date and time format as you wish. I think that logging will be better for you than the mail. And there is no database involved doing it this way.
<?php
function logIP()
{
$ipLog="logfile.txt"; // Your logfiles name here (.txt or .html extensions ok)
// IP logging function original by Dave Lauderdale
// Originally published at: www.digi-dl.com
$register_globals = (bool) ini_get('register_gobals');
if ($register_globals) $ip = getenv(REMOTE_ADDR);
else $ip = $_SERVER['REMOTE_ADDR'];
$date=date ("l dS of F Y h:i:s A");
$log=fopen("$ipLog", "a+");
if (preg_match("/\\bhtm\\b/i", $ipLog) || preg_match("/\\bhtml\\b/i", $ipLog))
{
fputs($log, "Logged IP address: $ip - Date logged: $date<br>");
}
else fputs($log, "Logged IP address: $ip - Date logged: $date\
");
fclose($log);
}
// Place the below function call wherever you want the script to fire. Keep it here to log page visits.
logIp();
?>
You can have more logs - one for each page - by changing the name for the logfile for each page like:
logfile01.txt on one page
logfile02.txt on another page
logfile03.txt on another page and so on.
**** The page must be of type PHP.
If you want to use the logging also on html.pages you can have the script in a PHP-file you "call" from a html.page using a PHP include inside the html.
The script can be made so it logs: IP, city, country, device type, platform and date and time.The city may not be very accurate.
https://helpcenter.websitex5.com/pt/post/235229
.
Hello Remus
Have you seen this: https://helpcenter.websitex5.com/pt/post/263273
Maybe it is something that you could use. It can be used on a whole X5-project by just inserting one line of code - or on specific pages whatever they are html or php pages.
Autor
Hello. Yes that's crazy nice. Unfortunetly as you guessed i am simply unable to do that all by myself. But YES is something really nice.
I guess it was you that just visited from RO.
If you will help testing, then I will help you by installing when test has ended. Just one folder to install on your server and one line in your X5-project, so maybe you will be able to install without help.
I expect it will be in the coming week the testing will be finished.
You could help by accessing the site with different devices and then report if the shown information is correct.
Autor
Great. i have some locations to test.(Not si many but i have). Also i can easy use some known positions vpn's to give a test also. Exactly i was visited from RO. Ok i will write on that post if is accurate or no. Thank you again.
Also try Microsoft Clarity - which shows you where on the page your visitor moused to...
Autor
I figured out. Actualy is not so complicated for who know some html and php. Is not the best way but for me it was worked just fine and now i recive a email evry time a particular page is hit and i know what page is since i was setup a page_id.