Solved

Outbound Link tracking

Posted on 2003-11-06
6
221 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
PERL get the value for query 4 163
Perl strange behaviour 5 79
perl to convert excel to csv 3 342
Using Perl DBI to query oracle 3 54
Email validation in proper way is  very important validation required in any web pages. This code is self explainable except that Regular Expression which I used for pattern matching. I originally published as a thread on my website : http://www…
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…

752 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