开发者

how to track from where visitor come to my site php

开发者 https://www.devze.com 2023-02-05 06:01 出处:网络
I want to track the site URL from where user reached my site. From where he came i.el, Google, GMail, Facebook, etc.

I want to track the site URL from where user reached my site.

From where he came i.el, Google, GMail, Facebook, etc.

I tried $_SERVER['HTTP_REFERER'] but it does not contain anything when user click on my site link from any external site but resides the value when I visit among my site pages and this is also not trusted.

So, What I can do from here?

Is there any other way to track the external URL through PHP?

Any idea?

EDIT: Now HTTP_REFERER is able to get the url from most of sites but not able to get the url if user came through Gmail and AOL. What coul开发者_运维知识库d be the causes?


HTTP_REFERER is the only way to get any information about previous site.

And that is also up to the broser if it supplies that information, most do as default.

Its a header that is set by the browser in the request to your server, if it is not present, then you will never know where the user came from.

If the browser is sending and you still to not get anything on the server check if you have any code that interferes with the $_SERVER variable.

Try this URL, its a google search result that goes to a page that just dumps the HTTP_REFERER.

As the pages indicates, if the box lists (none), then your browser is not sending HTTP_REFERER but if you get a result then the problem is in sour server.

http://www.google.com/url?sa=t&source=web&cd=1&sqi=2&ved=0CBIQFjAA&url=http%3A%2F%2Fkarmak.org%2F2004%2Freftest%2Ftest&rct=j&q=http_referer%20test&ei=cNQ2TdGYGsmUOp_ExPoD&usg=AFQjCNFVSmYmQBUcL2l3_ZpmZzVWZztjWg&cad=rja

You can compare it to when you load the page withour google to redirect you:

http://karmak.org/2004/reftest/test

Here is their own start page with link:

http://karmak.org/2004/reftest/


Have you tried it in a variety of browsers? It's down to the browser (As far as I'm aware) to set HTTP_REFERER and sometimes privacy settings can prevent this.


Visitors coming from google can be tracked using google analytics, it gives you the search query terms used before.

This solution also track a lot of other things from your visitors. I undertand it's not PHP based, but it's the only other kind of solution I know if HTTP_REFERRER is not enough to you, and as you quoted google...

0

精彩评论

暂无评论...
验证码 换一张
取 消