Announcement

Collapse
No announcement yet.

Integrating TradeDoubler code

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Integrating TradeDoubler code

    Hi

    I have a piece of perl code (included below) that I have given by TradeDoubler in order to track my sales that come from Kelkoo. I assume the code goes into os000001.pl but I don't know perl at all so I have no idea where it needs to gowithin the script. Does anyone have any ideas? Additionally there are certain variables such as order number and order value that need to be dynamically added to the code for each order, how do I change this script in order to incluse these variables?

    Any help would be much appreciated

    Regards
    Bruce Wallace

    Perl Code:

    #!/usr/bin/perl
    use Digest::MD5;
    use CGI;
    use CGI::Carp qw(fatalsToBrowser);
    use CGI::Session;
    my $cgi = new CGI;
    #Set session either from cookie, request or undef, using sessionId
    my $session = new CGI::Session(undef, $cgi, {Directory=>File::Spec->tmpdir});
    print CGI->header(), CGI->start_html();
    #This part should be implemented after you have retrieved all variables and displayed
    #the receipt.
    my $tduid = $session->param(-name=>'tduid');
    my $cookie = CGI->cookie("TRADEDOUBLER");
    if ( !$cookie eq "" ) {
    $tduid = $cookie;
    }
    $ctx = Digest::MD5->new;
    $ordernumber = "111";
    #ordervalue = total including shipping and taxes.
    #Cannot consist of , (comma) or spaces. Important no thousand separators.
    #Decimal sign is . (dot).
    #Shall be 1 if tracking a lead
    $ordervalue = "102.50";
    #organization = id number, provided by TradeDoubler
    $organization = 222404;
    #Supplied by TradeDoubler
    $event = 1212;
    #secretcode = integer to use in checksum algorithm, provided by TradeDoubler
    $secretcode = "1121";
    #currency = 3-letter code for currency of value1. Only needed if tracking a sale.
    $currency = "GBP";
    #Here is the checksum algorithm
    #v04 stands for version 4 of checksum.
    $ctx->add($secretcode . $ordernumber . $ordervalue);
    $checksum = "v04" . $ctx->hexdigest;
    #////////////////////////(Optional feature)///////////////////////////
    #Product report
    #Example product (you can add multiple products.
    #Add | between them (f1...&f2...&f3...|f1...&f2...&f3...) )
    #f1 is product number
    #f2 is product name
    #f3 is product value. Use dot (.) as decimal sign and no thousand separators.
    #Bellow is an example, you must replace the products values.
    $reportInfo = "f1=ProdNR01&f2=ProdName1&f3=100.00|f1=ProdNR02&f2=ProdName2&f3=1000.00";
    #Important! reportInfo parameter need to be URLEncoded in UTF-8 format.
    $reportInfo = urlencode($reportInfo);
    #////////////////////////(Review)///////////////////////////
    20
    CONFIDENTIAL
    This product is the subject of patent no. 9904115-4, filed 1999 - 2001
    © 2004 TradeDoubler AB
    #//review info. This information should be provided if customer is participating
    #//in a review
    #//name is the customers name
    #//email is the customers email
    #//expDeliveryDate is the expected delivery date of the purchase
    $review = "name=A Andersson&email=a.andersson@hotmail.com&expDeliveryDate=2005-09-01";
    #Important! review parameter need to be URLEncoded in UTF-8 format.
    $review = urlencode($review);
    #//Example where the customer has accepted to receive a review email
    $reviewApprove = $cgi->param('reviewApprove');
    #//The review parameter should be empty if the customer should not get a //review mail
    if(($reviewApprove eq '')){
    $review = "";
    }
    #=======================================================================================#
    sub urlencode{
    my($esc) = @_;
    $esc =~ s/^\s+|\s+$//gs;
    $esc =~ s/([^a-zA-Z0-9_\-.])/uc sprintf("%%%02x",ord($1))/eg;
    $esc =~ s/ /\+/g;
    $esc =~ s/%20/\+/g;
    return $esc;
    }
    #=======================================================================================#
    #/////////////////////////////////////////////////////////////////////
    print "<img
    src=\"http://tbs.tradedoubler.com/report?organization=$organization&event=$event&orderNumb
    er=$ordernumber&orderValue=$ordervalue&currency=$currency&checksum=$checksum&reportInfo=$r
    eportInfo&tduid=$tduid&review=$review\" >\n";
    #To test if TradeDoubler works, login on the website and click on "Check #implementation"
    #in the menu. Follow the instructions on this page to complete the test.
    print CGI->end_html();
    Bruce Wallace
    Picchu Maternity
    Designer Maternity Wear UK

    #2
    This code is a complete script which needs to be the target of a URL and will return a HTML page. This is not the type of code that can simply be added to the OrderScript. Normally Sales Tracking requires just an image link with a URL which includes some order details.

    Kind regards,
    Bruce King
    SellerDeck

    Comment

    Working...
    X