Easy Web Site Personalization With PHP
Copyright ©2003 Steve Shaw
Is your web site dynamic enough to address your visitors
by name?
If not, you are missing out on a powerful personalization
strategy that could treble your sales or more.
This article gives you a simple five step process you can
follow to quickly add some personalization to your web
pages. All you need to use is a bit of PHP.
If the mere mention of PHP fills you with programming
paralysis, you have no need to fear. It's incredibly
simple, not much more difficult than HTML - if you can do
basic HTML, you can do PHP.
The vast majority of hosts, both on Windows and Unix,
support PHP - if you're unsure, just check with your host.
STEP 1: Make Your Web Page a PHP Page
Most web pages end with the extension .html or .htm. All
you need to do is change this to .php (or occasionally
something like .php3 depending on your host).
One note of caution - if you are using SSI, there may be
SSI commands on your page that will need to be converted to
PHP commands. This is outside the scope of this article.
Also, if you normally use something like FrontPage, you may
run into problems with this, so just use something like
Notepad instead.
STEP 2: Create A Box For The Name
We are going to store the visitor's name in what is
commonly called a 'variable', so that we can use it later
on your web page.
All you need to do is put the following code at the very
top of your web page:
<?php
if(!$f){
$name = "Friend";
}
else{
setcookie("name","$f",time()+315360000,"/");
$name = $f;
}
?>
Replace 'Friend' with whatever term you want to use to
address visitors if you haven't yet captured their name -
we talk about how to capture their name later in this
article.
Don't worry about what the rest of this code does. It's
just there to make sure the whole system works - if the
visitor's browser allows cookies, they'll still see their
name when they revisit your web site in the future.
STEP 3: Capture Their Name
This is the bit where you throw a rope round their name
and string it up on your web site to grab their attention!
Here's one way to do it - just add a bit extra to the
normal URL to your web page.
Take a look at this example:
http://www.yourdomain.com?f=Fred
You just add ?f=Fred (or whatever the first name of the
person is) to your URL.
Yes, I know - this is only useful if you provide a link in
something like a newsletter, and if you use a mailing
service that permits personalization. But some solo ad
publishers also permit personalization, so you can use it
there too!
Another way is to capture their name when they fill in a
form to subscribe to your ezine, for example. But this
would require more space than I have room for in this
article.
STEP 4: Speak To Them By Name
So you've got their name - now you can use it to speak to
them in person across your whole web site!
Here's how you do it.
Wherever you want to display their name, just type in the
following instead:
<? echo ($name); ?>
As long as your web page is a PHP page, as discussed in
Step 1 above, this will display the visitors name, if you
have it. Otherwise it will display the default, which in
my code above is 'Friend'.
STEP 5: Upload The Code
Upload the PHP page to your web site, and test it.
First visit the page normally, for example going direct to
http://www.yourdomain.com/index.php - you should see
'Friend' wherever you wanted the first name to go to.
Now visit it by typing a URL like the following into your
browser: http://www.yourdomain.com/index.php?f=Bob.
Wherever it said 'Friend' it should now say 'Bob' - you may
need to reload the page to overcome the browser cache.
There's no better way to grab your visitor's attention
than to actually address them by their first name!
Master programmer and internet marketer Steve Shaw provides
specialist programming solutions for profitable web sites
at http://takanomi.com
Publishers - you are free to republish the article above as long as it's printed in its entirety along with the resource box. You can receive a copy of the article preformatted and ready for publication by simply filling in the form below and clicking the button - you will not receive any further mailings as a result of this article request.
Top Software
Recommended
E-Marketing Articles
Newsletter
|