Do I need IPN for affiliate tracking code?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi there,
I am new to the business side of paypal and am rather confused.
I have a business paypal account and have created a page in my website where I sell gift vouchers. I created several paypal buttons for different items on this page. All charge a different amount depending on which size book and how many pages a customer wants to buy (I think this is irrelevant info, but decided to add it to try to be complete). All buttons are setup to go to my own confirmation page. I have called it paypasuccess.htm and it simply displays a 'thank you' message and some basic info on how they will receive their gift voucher. (I intend to send them via email, happy to start this manually until I have enough volume to make it worth my money to set it up automatically, at the moment I need to generate the code for the voucher first and add it to a pdf voucher which is then emailed to the customer).
So far so good, it all works, I'm happy.
Now I recently signed a contract with an affiliate marketing agency. They market my product and for every customer that comes through their website I will pay them a commission. This commission is paid at the end of the month. They then pay airmiles to the customer for the amount they spent. So in order to know who came via their website, they want me to implement a tracking code.
It is basically a 1x1pixel image that needs to sent the variables for 'customer ID' and 'total amount spent' back to their server where it will be processed to create my monthly invoice at the end of the month.
I have tried to read forums etc and even sent the x.com people an email with my question, but I am not getting useful info back. (am I asking the wrong questions?). I was told that the variables are called: 'txn_id' and for the total amount it would be: 'mc_gross' (as my payments are in AUD not in USD).
Knowing what they are called is one step, but now the big questions is, can I simply add this line of code (with the variables included) into my confirmation page (where all customers are automatically send back to after buying something)? Or do I have to set up this whole 'listener' and use IPN to get this information back to my affiliate marketing agency?
Or is this something I have to do with PDT?
IF I have to do this with IPN, API or PDT, where do I find somebody with the skills to set me up in such a way I can easily still change buttons and the info will still be send to the affiliate marketing agency?
Sorry for the long story, I am really hoping somebody out here can help me point my nose into the right direction. I am not even sure if I am asking the right questions. All I know is I need to add this tracking code to the confirmation page of each sale and change these variables so they send my info back to the affiliate marketing agency. Once I have done that I can launch my website with them!
Hope to hear from somebody soon!
Thanks,
Jude

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi pix2print!
Welcome! 🙂
I would be confused too. Setting up these affiliate tracking systems can be pretty challenging.
Based on your description, here's how I imagine this working:
- The customer starts out on the marketing agency website and they click a link to your site.
- Your site needs to identify that the customer is coming from that website and mark the transaction differently from other payments.
- Once the payment is complete, the customer is redirected back to your thank you page where you plan to integrate the tracking pixel to notify the marketing agency of the sale.
In this case, your site would need to detect the referring URL then dynamically modify the button code to include a custom variable to identity that this was an affiliate referral. Once the payment is complete, a PayPal IPN would notify you of the sale and include that custom variable so your server knows it was an affiliate sale. Your server would then need to notify the marketing agency. Easier said than done. In this scenario, your website would need custom code to modify standard PayPal button code and your IPN listener would need to be customized to notify the marketing agency.
I don't recommend using PDT for this because PDT depends on the customer's browser being successfully redirected to your website. If the buyer closes the tab or browser before that happens, your site wouldn't receive the payment information and the tracking pixel wouldn't load on your thank you page. Alternatively if you use the tracking pixel before they are redirected to PayPal and they never finish the payment, we don't want you to be invoiced for a sale that never occurred.
At this point, I would ask the marketing agency if they have any recommendations or hire a developer to get this up and running. You can find a list of PayPal developers here:
PayPal Certified Developer Directory
I hope this helps to get you started on the right path to a solution. 🙂
- Frank
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Frank,
Thanks a lot for your help, much apppreciated!
You are pretty much spot on how it is supposed to work, unfortunately the marketing agency hasn't been able to help as they claim they can't provide solutions as many merchants use many different systems, so I am on my own here.
- Customers have to log in to their website (it is a frequent flyer program) and then click through to my website.
- Once there, customers can select what they want and click the buttons to buy, this takes them to paypal.
- They won't be closing their browser before they are returned to my thankyou page as that is where they will see the confirmation of payment (they don't go to a paypal site where they have to click to return to my site, I have set it up in each button that the 'success' page is mine, not from paypal).
- The tracking info will go straight to their server, not mine as I will have payment info on the paypal site.
- Every month I will go through the list as received by marketing agency to verify if all payments were completed and customers haven't requested a refund.
I think this means I can safely use PDT, based on what you wrote and don't think I will be charged for purchases that weren't completed (as the tracking pixel is on the thankyou page).
I have tried to set up the variables that need to be sent as follows:
- <img src='https://www.tagserve.com.au/saleServlet?MID=43&PID=55&CRID=&ORDERID=’txn_id’&ORDERAMNT=’mcgross’&NUM...' border='0' width='1' height='1'>
(with single quotes around the names of the 2 variables)
And like this:
- <img src='https://www.tagserve.com.au/saleServlet?MID=43&PID=55&CRID=&ORDERID=$txn_id&ORDERAMNT=$mcgross&NUMOF...' border='0' width='1' height='1'>
(with $ in front of the variable names)
The php script I am using (from the paypal site):
<?php
/*
update: 06/27/2011
- updated to use cURL for better security, assumes PHP version 5.3
*/
// read the post from PayPal system and add 'cmd'
$req = 'cmd=_notify-synch';
$tx_token = $_GET['tx'];
$pp_hostname = "www.paypal.com";
// read the post from PayPal system and add 'cmd'
$req = 'cmd=_notify-synch';
$tx_token = $_GET['tx'];
$auth_token = "**removed by moderator**";
$req .= "&tx=$tx_token&at=$auth_token";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://$pp_hostname/cgi-bin/webscr");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $req);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 1);
//set cacert.pem verisign certificate path in curl using 'CURLOPT_CAINFO' field here,
//if your server does not bundled with default verisign certificates.
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Host: $pp_hostname"));
$res = curl_exec($ch);
curl_close($ch);
if(!$res){
//HTTP ERROR
}else{
// parse the data
$lines = explode("\n", $res);
$keyarray = array();
if (strcmp ($lines[0], "SUCCESS") == 0) {
for ($i=1; $i<count($lines);$i++){
list($key,$val) = explode("=", $lines[$i]);
$keyarray[urldecode($key)] = urldecode($val);
}
// check the payment_status is Completed
// check that txn_id has not been previously processed
// check that receiver_email is your Primary PayPal email
// check that payment_amount/payment_currency are correct
// process payment
$firstname = $keyarray['first_name'];
$lastname = $keyarray['last_name'];
$itemname = $keyarray['item_name'];
$amount = $keyarray['payment_gross'];
echo ("<p><h3>Thank you for your purchase!</h3></p>");
echo ("<b>Payment Details</b><br>\n");
echo ("<li>Name: $firstname $lastname</li>\n");
echo ("<li>Item: $itemname</li>\n");
echo ("<li>Amount: $amount</li>\n");
echo ("");
}
else if (strcmp ($lines[0], "FAIL") == 0) {
// log for manual investigation
}
}
?>
The script seems to work as it returns hard coded names for the variables I need returned (txn_id and mc_gross), but neither with single quotes around the variable names or with $ before them does it work.
Do I need to adjust things in the script for the PDT to work?
Sorry to bombard you with all these questions, but if I can get the PDT to work and don't have to resort to finding a developer to set up the complicated IPN option I would really prefer that.
Thanks again for helping out!
Cheers,
Jude

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi pix2print,
I'm happy to help. 😄
pix2print wrote:...
3.They won't be closing their browser before they are returned to my thankyou page as that is where they will see the confirmation of payment (they don't go to a paypal site where they have to click to return to my site, I have set it up in each button that the 'success' page is mine, not from paypal).
I think this means I can safely use PDT, based on what you wrote and don't think I will be charged for purchases that weren't completed (as the tracking pixel is on the thankyou page).
...
You're right. They probably won't close the browser. But I still want to clarify that if the browser or tab gets closed for any reason between the time the payment is successfully sent and the time they are redirected back to your website, the PDT script will never receive the txn_id and mcgross values. I must still recommend using IPN if you need to reliably receive that information. Hopefully that never happens but I just want to make sure you're aware of that possibility.
To get the txn_id and mcgross to appear in the img source url, you'll want to use "echo" within the PHP script. So it would look something like this:
echo ("<img src='https://www.tagserve.com.au/saleServlet?MID=43&PID=55&CRID=&ORDERID=$txn_id&ORDERAMNT=$mcgross' border='0' width='1' height='1'>\n");
You could put this code with the other echo lines in the php script.
- Frank
I provided code so I need to post an obligatory disclaimer:
You will need to know PHP and HTML to properly implement this solution but please note this code is provided AS IS. It is your responsibility to ensure the accuracy and integrity of this code. This code is provided purely as an example. PayPal does not support this code. Make sure you check all of the code and test it throughly before placing this code on a production server.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Frank,
Sorry I haven't responded earlier... I have been trying to get it right and your code was pretty spot on, but unfortunately paypal doesn't seem to want to send the 2 variables to the TAG server (from Virgin) without an SSL ccertificate. At least that is what it seems like at the moment. I guess it makes sense that they don't want to send any customer details without a security certificate...
I added your code into the php script and it shows the details in the URL, so far so good, but now they still need to get to the other server. I have asked my server provider to add an SSL certificate, so as soon as I have that I can continue the testing.
I will keep you informed on progress! Very much appreciate your time!!!
Have a good night,
Jude

Haven't Found your Answer?
It happens. Hit the "Login to Ask the community" button to create a question for the PayPal community.
- I am seller. Send products, buyer opened case, won, received items for free in About Payments (Archive)
- Craigslist Nigeria fraud/Scam in About Protections (Archive)
- Buyer disputes that item wasn't received in About Business (Archive)
- The scammers are protected paypal. in About eBay (Archive)
- Payment Held in About Payments (Archive)