When I paste my website link at a social network (Facebook or Twitter for example), the social network access my site to show a preview to the user.
I want to separate this access from real access at my reports, but to do this, I need to identify this cases.
This kind of access send any kind of information that is default for everysite that I can identify that this access is not a real user, but a robot?
2 Answers
Answers 1
You should be able to identify those robots from their user-agent string. For example, Twitter uses the User-Agent of Twitterbot. And Facebook crawler identification is documented here.
Answers 2
You can use the User-Agent to do that.
if (strpos($_SERVER["HTTP_USER_AGENT"], "Twitterbot") !== false) echo "TwitterBot"; else if (strpos($_SERVER["HTTP_USER_AGENT"], "facebookexternalhit") !== false) echo "Facebook"; else echo "regular user";
https://developers.facebook.com/docs/sharing/webmasters/crawler
0 comments:
Post a Comment