Statistics for Syndicated Content
This article comes with a complete page view tracking
system for JavaScript syndicated content. You can find
out who is syndicating your content and how many times
the content is being viewed.
This system will also work with regular web pages. Put the
logging code into your web page content the same way you
would for syndicated content.
However, it was originally created for site owners who use
Master Syndicator V4 to syndicate content. Some people
don't need all the many golden features of Master
Syndication Gateway V2 and acquire Master Syndicator V4,
instead.
This article makes a statistics feature available to all
who syndicate with JavaScript.
This tracking system for JavaScript syndicated content comes
in 3 sections: The tracking code to paste into content being
syndicated and two scripts, a script for logging content
location and page views and another for viewing the data
in the log file.
The code and scripts for the system can be copied from the
online version of this article, URL at end of this ezine
version.
The Tracking Code
The tracking code is composed of JavaScript and a NOSCRIPT
tag. It calls the logging script with an image tag.
The JavaScript sends the URL of the page where the content
is at (the web page syndicating your content). JavaScript
is used for this because more and more browsers are not
providing page referrer information. The JavaScript also
uses a random number to bypass browser image cache.
The image is a clear GIF, generated from within the logging
script. Its size can be any you prefer
If the browser is not JavaScript enabled, the NOSCRIPT tag
kicks in. The same image tag URL is used, but no URL is
sent to the logging script. The logging script will,
however, use the referrer information if the browser
provides it. If the browser is not JavaScript enabled and
does not provide referrer information, it is so marked (as
blank) in the log.
The tracking code is the same for all content using the
system. It can be put into content templates if you use
them.
Here is the tracking code.
Replace both instances
of http://example.com/cgi-bin/counter.cgi in
the above JavaScript with the URL to the logging script.
The Logging Script
This script creates and updates a tab-delimited file
suitable for importing into spreadsheet software, if you
wish to manipulate the data that way.
Each record has 4 fields.
-
A 10-digit number representing the date and time of
the page view (according to the server's clock). It
is for use by file scanning software.
-
The server date in human-readable format.
-
The server time in human-readable format.
-
The URL of the web page where the content is being
syndicated. If the browser being used is not
JavaScript enabled and does not provide referrer
information, this field will be blank.
There is one record for each recorded page view.
Here is the logging script.
Save the file under a name that makes sense to you.
The location of the log file needs to be specified at
the only configuration line of the script. The location
you specify here must also be specified in the data viewing script.
The Data Viewing Script
Once installed, the data viewing script is very easy to use.
Simply type its URL into your browser, specify the start
and end dates for the data you want to view, and click the
button. You'll get a nice report.
If you specify no dates, cumulative data for the entire
file will be used to generate the report.
The report has four columns.
-
The left-most column is a colored bar representing
the number of views compared to the other pages in
the report.
-
The second column is a number stating the number
of recorded page views.
-
The third column is a percentage representing how
often the page was viewed as compared to the total
number of page views the report covers.
-
The last column is the URL of the web page,
clickable.
Below the report is a form for generating another report.
Here is the data viewing script.
Save the file under a name that makes sense to you.
If the statistics are information no others should have
access to, give this script a file name not easily guessable
to give yourself a bit of protection.
The location of the log file needs to be specified at
the only configuration line in the script. The location
must point to the file that the personal statistics
gathering script updates.
Installation
Grab a copy of the tracking code and two Perl scripts
from the online version of this article (URL below).
Upload both Perl scripts as plain text (not as binary
files) with an FTP program. Give the scripts 755
permissions.
Type the URL of both scripts into your browser to verify
they work as intended.
After the logging script has been loaded into the browser,
there should be a log file where you specified it to be.
The data viewing script should find the log file and
display the hit.
Once both scripts are working as intended, put the tracking
code into some content and try it out.
When the content is loaded into your browser, the logging
script should make an entry to record the fact. And the
data viewing script should find the entry and display it.
Once all works as it should, the tracking code can be
pasted into as many different syndicated content files
as you wish, even in the content in normal web pages of
your own web sites.
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
©2006 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.