Solved

Outbound Link tracking

Posted on 2003-11-06
6
215 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
binary to char / hexadecimal 5 104
Port 80 requests 16 86
Question about @INC variable in perl 1 55
Perl Frameworks 1 77
On Microsoft Windows, if  when you click or type the name of a .pl file, you get an error "is not recognized as an internal or external command, operable program or batch file", then this means you do not have the .pl file extension associated with …
There are many situations when we need to display the data in sorted order. For example: Student details by name or by rank or by total marks etc. If you are working on data driven based projects then you will use sorting techniques very frequently.…
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…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

929 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

10 Experts available now in Live!

Get 1:1 Help Now