Landing Page Cookie
When a sale is made, which landing page did the customer
see first?
When visitors subscribe to an ezine, which page of the
web site did they see when they first arrived?
What percentage of visitors arriving at your landing
page follow through?
Maybe it doesn't matter. And maybe it does.
If you knew for a fact that 12% of everybody who lands
at pageone.html goes on to buy a widget from you, but only
2% of those who land on pagetwo.html, you would have
information with which to work. You could tweak pagetwo.html
to convert better or change your advertising and links so
pageone.html gets most of the traffic, or both. Or ignore
it.
The information gives you a choice.
This article will show you how to implement a system of
logging the landing page whenever a conversion is made.
The landing page sets a cookie identifying the page. The
conversion's "thank you" page logs the cookie. You import
the log into your spreadsheet to see the results.
How it Works
Three things happen, two are caused by the site visitor
and one by the site owner.
-
When the visitor arrives, the landing page sets a
cookie. The cookie identifies the landing page (so you can
enable many landing pages, if you wish).
-
When the visitor
buys or subscribes or takes other desired action, the
conversion "thank you" page automatically sends its own
identification, along with the value in the cookie, to a CGI
program. The CGI program logs the event. (A conversion
"thank you" page is the web page displayed immediately after
the desired action is completed.)
-
Intermittently, or on a
schedule, the site owner downloads the log file (which is a
CSV file) and imports it into desktop spreadsheet software
for studying and calculating.
For the cookies to work, the landing page and the
conversion "thank you" page must both be on the same domain.
The domain is the domain portion of the URL used to access
the page.
If one page is accessed with http://example.com/... and other other
with http://www.example.com/ then those are
two different domains as far as cookies are concerned. If
the landing page URL contains "www." in the domain name,
then the conversion "thank you" page URL must also contain
"www."
The Perl CGI script can run on any domain so long as the
server is Unix/Linux.
How to Implement the System
There are three scripts, two JavaScript and one Perl.
One of the JavaScript scripts is for inserting into the
landing page (or pages). The other JavaScript script is for
inserting into the conversion "thank you" page (or pages).
And the Perl script is to be installed as a CGI program.
Implementation Step 1
First, install the Perl CGI script.
You may wish to change the log file name before
installing. If the log file is to be written to a location
other than where the script is to be installed, include
directory path information with the file name.
Once the Perl CGI script is installed, test it by typing
its URL into your browser.
Verify that the script creates the log file. (The log
file created by this test may be deleted the script
creates the file as needed.)
Implementation Step 2
Now, determine which of your web pages shall be a
landing page. Insert the cookie setting JavaScript into the
web page.
The higher in the page you put the JavaScript, the
sooner the cookie will be set. The JavaScript can be
inserted into the HEAD or BODY area of the source code.
A cookie name needs to be specified in the JavaScript.
It doesn't really matter what the name is, so long as it
begins with a letter, is composed only of letters and
numbers, and, importantly, the same name is used in the
JavaScript for the conversion "thank you" page
(implementation step 3).
The second decision to make is how long the cookie shall
last.
Things to consider:
-
Once the cookie is set, it will not be overwritten by
any landing page of this system so long as the cookie
exists.
-
A conversion "thank you" page will launch the logging
CGI script only when a cookie is present.
-
Once the cookie expires, it can be overwritten.
The JavaScript is marked where you can specify the
cookie name and the number of days the cookie shall exist.
Put the JavaScript into one landing page. After testing
proves everything works as it should, other landing pages
can be enabled with the JavaScript.
Implementation Step 3
For this final implementation step, determine which of
your confirmation "thank you" pages shall launch the logging
script. Insert the cookie retrieving JavaScript into the web
page.
The higher in the page you put the JavaScript, the
sooner the cookie will be set. The JavaScript can be
inserted into the HEAD or BODY area of the source code.
A cookie name must be the same name as specified in the
cookie setting JavaScript for the landing page (implemented
in step 2).
The second customization is to specify the URL to the
Perl CGI script you installed in implementation step 1.
The JavaScript is marked where you can specify the
cookie name and the Perl CGI script URL.
Put the JavaScript into one confirmation "thank you"
page. After testing proves everything works as it should,
others can be enabled with the JavaScript.
Testing
You've tested the Perl CGI script installation in
implementation step 1. All that's left is to test the
landing page and confirmation "thank you" page JavaScript.
To test, go through the motions a site visitor would.
Then download the log file and import it into your desktop
spreadsheet software.
When everything works okay, you're good to go.
Delete the testing log file from the server, just so you
don't have your testing clutter in the file.
The Perl CGI script will make a new log file whenever it
doesn't find one already existing.
Question:
Did you find this article interesting and understandable? How can it be improved?
Your response is anonymous.
When done typing, click anywhere outside the box. [more info]
Will Bontrager
©Copyright 2006 Bontrager Connection, LLC Bontrager Connection, LLC
Please note:
Articles on this website are presented "as is". However -
If you have a question about a CGI script, HTML, CSS, PHP, or JavaScript
Ask one of our Experts and you'll have your answer!
Click here for details.