≡ Menu

Show different content for PPC users with PHP

I just recently created a new site for a client and he decided he wanted to do PPC. I created a landing page for him. I still wanted the users to be able to see the rest of the site but I wanted to show a specific phone number to PPC visitors. I created some PHP code that gives a 10 year cookie to anybody who hits my PPC landing page. On every other page in my site I put in some code that checks for that cookie and gives then a PPC phone number if they find that cookie.

Code for PPC landing page. Must be very first thing on page.

setcookie("ppc", "this works", time()+60*60*24*365*10);
?>

Code for every other page.

if (isset($_COOKIE["ppc"]))
echo 'ppc info';
else
echo 'non ppc info';
?>

You can use that code to display a different logo or image with phone number in it or special text. If you have your phone number all over the place I would put your phone numbers in different include files so that you can change them easily.

Code for include

if (isset($_COOKIE["ppc"]))
include 'ppc-phone.inc';
else
include 'phone.inc';
?>

[tags]ppc, php, adwords, SEM[/tags]

Comments on this entry are closed.