I am trying to create some stats and need to print a users referal site, or search keyword. How to get a Users referal site or search keyword with javascript and print it?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can use
document.referrer( some info on mdn or w3c ).Edit :
For search kewords work on the referrer, for example searching “hello world” on google gives a referrer like this if searching directly ( adress bar or search bar ) :
But searching hello world typing in google is done with ajax ( the parameter is after the # in the hash ) and gives you a referrer like :
So you could just have to search the
&qparameter and see if there is/url?replace%20by space, otherway replace+by space :For yahoo you get a referrer like :
So you could add :
The
decoreURIComponentis for special chars ( +, #, & and foreign characters ).And you will have the keywords from yahoo or google ( but you could change google domains ( the
(be|fr|com)) and treat the case of other search motor.