[Webinar] Streamline your web hosting managementRegister Today


Show specific image based on visitor's referrer

Posted on 2010-04-06
Medium Priority
Last Modified: 2012-06-27
I would like a script that will show an image (called from an external website) to visitors of my website ONLY if they've come from a Bing search engine result.

For example:

If a visitor arrives on my site via a Bing search result, then I would like the results of the following code shown to them;

<img width="65" height="37" border="0" src="//www.examplesite.com/image1.gif" alt="blah">

However, if they came from any other referrer (or just typed-in the URL), then they will not be shown the above code. (Obviously I don't mind it being present if they look in the source code.)

Hope this makes sense. Thanks.
Question by:phaygarth
LVL 12

Accepted Solution

jet-black earned 2000 total points
ID: 29937608
Try this:

if (isset($_SERVER['HTTP_REFERER']))
    $parseUrl = parse_url($_SERVER['HTTP_REFERER']);
    if ($parseUrl['host'] == "www.bing.com" || $parseUrl['host'] == "bing.com")
<img width="65" height="37" border="0" src="//www.examplesite.com/image1.gif" alt="blah">

Open in new window


Author Closing Comment

ID: 31711485
Perfect, thanks.

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A while back, I ran into a situation where I was trying to use the calculated columns feature in SharePoint 2013 to do some simple math using values in two lists. Between certain data types not being accessible, and also with trying to make a one to…
This holiday season, we’re giving away the gift of knowledge—tech knowledge, that is. Keep reading to see what hacks, tips, and trends we have wrapped and waiting for you under the tree.
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
Suggested Courses

607 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question