Solved

Outbound Link tracking

Posted on 2003-11-06
6
217 Views
Last Modified: 2008-02-01
Hi,

I'm trying to find a script(preferably perl) that can track an outbound link and write the data to a MySQL DB.

Can anyone point me to any examples or starting points?

--Maverick
0
Comment
Question by:MAVERICK
6 Comments
 

Accepted Solution

by:
elsamman earned 125 total points
ID: 9702015
Sorry but what do you mean by an 'outbound link'?

...Sam
0
 
LVL 1

Author Comment

by:MAVERICK
ID: 9702198
Hi Sam,

A link from my website to another website. An example is http://www.maverick.local/redirect.pl?url=http://www.exampledomain.com

I know how to do a redirect btw. I'm hoping someone has an example for logging the link access to a database.

--Maverick
0
 
LVL 8

Assisted Solution

by:jhurst
jhurst earned 125 total points
ID: 9726385
when I need to do this I do something like
 redirect.cgi?http://www.maverick.local/redirect.pl?url=http://www.exampledomain.com

my redirect cgi is :
#!/usr/bin/perl

$where2=$ENV{QUERY_STRING};
open(LOG,"">logFile");
print LOG <<EOT;
we transfered to: $where2
EOT
close(LOG);

print <<EOT;
Status: 302 re-direct
Location: $where2

EOT

exit;
0
 

Expert Comment

by:elsamman
ID: 9726662
OK.

This should do the trick.  I assume that

- Your user-id is xxx
- Your password is yyy
- You created a database called xxx_logging
- You went into mysql and created a table in that database with a statement such as:

use xxx_logging;
create table logging (url text);

Use this script to log the URL and then redirect to it (replace xxx and yyy)

#!/usr/bin/perl
use CGI;
my $cgi = new CGI;
my $url = $cgi->param('url');
use DBI;
my $dbh = DBI->connect("DBI:mysql:xxx_logging:localhost", 'xxx', 'yyy') or die 'Cannot open database';
my $stmt = "insert into log_table (url) values ('$url');";
my $sth = $dbh->prepare($stmt);
$sth->execute() or die "Cannot execute $stmt";

print $cgi->redirect($url);

Now in practice I would create a different user-id for the database than your actual UNIX ID since you don't want to embed that in a script.



0
 
LVL 20

Expert Comment

by:jmcg
ID: 10089860
Nothing has happened on this question in more than 8 weeks. It's time for cleanup!

My recommendation, which I will post in the Cleanup topic area, is to
split points between jhurst [50 pts] and elsamman [200 pts].

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

jmcg
EE Cleanup Volunteer
0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Suggested Solutions

In the distant past (last year) I hacked together a little toy that would allow a couple of Manager types to query, preview, and extract data from a number of MongoDB instances, to their tool of choice: Excel (http://dilbert.com/strips/comic/2007-08…
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

813 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now