: How to detect conversions in a configuration with a simple Paypal Buy button? I have a simple flow with a Paypal button: Website example.com ===> Paypal interface ===>
I have a simple flow with a Paypal button:
Website example.com ===> Paypal interface ===> Payment success page
[simple Paypal BUY button] example.com/success
[ without cart ]
I would like to track conversions with Google Analytics and Facebook ads manager.
In order to do that, I have set a "Goal" in Google Analytics: When example.com/success is visited, it is a purchase. The same can be done with Facebook ads (see screenshot below).
Problems:
sometimes, after Paypal processes a payment, the customer doesn't go back to example.com/success. Then the conversion cannot be tracked.
if someone visits the success page from multiple devices, it can be tracked as multiple conversions, which is a mistake!
Question:
How to detect conversions in a configuration with a simple Paypal Buy button?
Note: Here is how looks the conversion setup in Facebook:
More posts by @Murphy175
1 Comments
Sorted by latest first Latest Oldest Best
I finally found a solution. It works with Google Analytics, I haven't found for Facebook yet.
On your website, inside the Paypal button code <form>...</form>, add a field <input type="hidden" name="custom" value="(userid)"> where the userid is set with Javascript, taken from Google Analytics cookie, such as document.cookie's _ga.
This custom field will be passed to Paypal when the user clicks "BUY", and will be passed to IPN PHP code that runs after each successful payement. It can be retrieved in the IPN PHP code with $_POST['custom'].
In the Paypal IPN PHP code, you can send a request to GoogleAnalytics to manually trigger a pageview of a virtual page named example.comthisisapurchase. Something like this works:
$data = array('v' => 1, 'tid' => 'UA-xxxxxxx-x', 'cid' => $_POST['custom'], 't' => 'pageview', 'dh' => 'www.example.com', 'dp' => 'thisisapurchase', 'dt' => 'thisisapurchase');
$options = array('http' => array('method' => 'POST', 'content' => http_build_query($data)));
$context = stream_context_create($options);
$result = file_get_contents('https://www.google-analytics.com/collect', false, $context);
In Google Analytics, create a "Goal" with destination = example.comthisisapurchase
Then the visitor who visited the website, and who did a purchase (he visited a virtual page named example.comthisisapurchase) will be seen as one unique visitor in Google Analytics.
Then you can reliably know from which source he comes from (referral, affiliate, etc.)
Terms of Use Create Support ticket Your support tickets Stock Market News! © vmapp.org2024 All Rights reserved.