I have a wordpress site. If I include some javascript on a post, I show ads on the post. I want to only show that javascript when people come to my site from google search (as opposed to from twitter or facebook -- or by going to the URL directly).

Is there any way to do that from within wordpress?

1 Answer 1


Not a wordpress questions really. You will get much better responses at stackoverflow.com. However you instigated my curiosity... you can get the referral url by using the following javascript:


You could add that to your current AD script to check if the document.referrer == "some url" before displaying the ad.

See more examples here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.