PayPal integration with iframe-based cart - iframe

We use PayPal's Payments Pro NVP API to provide seamless credit card and paypal processing on our site. We've created an iframe-based cart widget that our customers put onto their site so their users can purchase items and pay via our Paypal account.
While credit card transactions work fine, we're seeing issues when a user tries to pay with their the PayPal account. The API uses a redirect when clicking the PayPal logo but then PayPal's code seems to run a framebusting script and the transaction can't continue.
I am seeking suggestions or sample code for how to handle users wishing to PayPal for their payment via the iframe. One option is to pop-up a new window but then it leaves the design open to issues since the user can switch between that window and the window containing the iframe and conceivably get the cart out of sync with what the PayPal window is displaying.

Both of the above answers are correct. However, PayPal tech support provided a more thorough set of instructions which I've provided below. Hopefully they'll help someone else.
Modify your SetExpressCheckout calls so that the RETURNURL and CANCELURL parameters point to a special return page that will handle closing the pop-up window for you and continuing the normal checkout process (more on this later).
Next, modify the script that redirects the buyer over to the PayPal website. Normally, this script would return a “302 Found” (or similar) response to the browser, telling the browser that it should follow a redirect to some other page. (In PHP, this is usually accomplished with the “header” function – e.g., header(“Location: https://www.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=$token”); .) Instead, this script should emit the following HTML/JavaScript code (replacing “TOKEN” with the token you received from PayPal). This will open a pop-up window where the buyer can continue the checkout process on PayPal. You can insert additional text, as you like, to indicate to the buyer that they should be using the pop-up window to complete their checkout. To avoid issues with pop-up blockers, you can create a link or button on your page, indicating to the buyer that they should click the link/button to continue, and use this code for the object’s “onClick” handler.
<script type="text/javascript">
window.open("https://www.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=TOKEN","_blank","width=1024,height=768,location=1,resizable=1,scrollbars=1,status=1",true);
</script>
Now, create a new page that executes the following code (or similar – this code is based on PHP, adjust as necessary for whatever language you are using). This code will close the pop-up window and continue the checkout process in your existing iframe. The RETURNURL parameter of your SetExpressCheckout call should point to this page. Replace “paypalreturn.php” with the script you currently use to handle buyers returning to your shopping cart from PayPal.
<html>
<body>
<script type="text/javascript">
window.opener.location="http://www.regattacentral.com/paypalreturn.php?token=<? echo $_REQUEST["token"]; ?>&PayerID=<? echo $_REQUEST["PayerID"]; ?>";
window.close();
</script>
</body>
</html>
Lastly, repeat this step for your CANCELURL handler.
• The purchase completes inside of the iframe, and the transaction ID for the purchase is shown.

PayPal Express Checkout / 'Pay with PayPal' in Pro Hosted does not support iframes for security reasons. Opening a pop up window (or setting target=_parent) is the only way to process this properly.

Set your form target to - target="_top"

Related

how to do multiple tracking like a series of pages one after another?

So,
I have a blog with a "demo button" with leads the user to a sign up page.
On sign up page, the user fill the general entries. Then he is brought to a payment page to enter his card details. and then from there he is taken to a confirmation page.
Now, I want to track every page. Basically, whether any user coming from a blog becomes a user or atleast how far he goes before closing the tab
Use Enhanced E-Commerce Tracking.
The EEC in Google Analytics lets you assign step numbers to the various steps in a checkout. It then creates a custom funnel report (remember that EEC must be enabled and configured not just in your code, but also in your view settings) that show how many users completed the checkout and how many dropped of at each step.

Reading POST Data after auto-return

On my .NET website I use both "Buy Now" and "Subscribe" buttons.
The "buy now" button works OK: after buying the visitor is returned to website and I see his Paypal details in POST (via Firebug), and I can access them with "Request.Form("...")
However, when I use "Subscribe" button, the user is returned to website with only empty GET request, as he was simply entering the URL.
I use custom buttons. I tried also Paypal generated button - the same effect - no POST section.
Both buttons are on the same page
I use auto-redirect defined in Paypal
IPN enabled (and works for "buy now").
How I can get the buyer's details when he does monthly subscription?
Are you using the return and rm parameters in your Subscribe button? PayPal's docs state the following for the rm parameter, which sounds like what you need to adjust.
Return method. The FORM METHOD used to send data to the URL specified
by the return variable. Allowable values are:
0 – all shopping cart payments use the GET method
1 – the buyer's
browser is redirected to the return URL by using the GET method, but
no payment variables are included
2 – the buyer's browser is
redirected to the return URL by using the POST method, and all payment
variables are included The default is 0.
Note: The rm variable takes effect only if the return variable is set.

Google Analytics Tracking Conversions with vendor data and custom campaigns

Please help me understand this. I have a client for whom we created a sweepstakes "mini site". Traffic was generated through banner ads, eBlasts, and newsletters. For the banner ads, I created custom urls, i.e. www.somewhere.com?utm_source=yahoo?utm_campaign=abc to track the traffic to the landing page per vendor/banner. this works just fine.
The entrant visits the page, signs up for the sweepstakes, has as double opt in email process for verification. All of my entering traffic to the landing page is tracking fine, and is properly broken down by utm_source and utm_campaign.
Some of the vendors had me place tracking pixels on the confirmation page for conversion statistics. The only info I have placed for internal tracking on the confirmation page is the GA tracking code.
I have been told to create tracking pixels to track the individual vendor conversions. Is this possible without the originating pixel data from the vendor? I am new to tracking pixels, but my understanding is that I need some information from the vendor in order to write the code for the pixel. Am I wrong?
I can't understand how we can place a tracking pixel on our end without at least campaign name or data from the vendor's tracking pixel that they placed on the page containing our banner ads.
What am I missing here? How can I actually separate the conversion traffic from the different sources when everyone receives the same double-opt-in email?
Please ask me to clarify if I am not being clear. Thanks in advance for reading my question.
There are two things you are trying to track here. One is Campaigns: Campaigns are how you measure the effectiveness of techniques to bring users to your site.
The other thing you are tracking is Events - this is what users are doing once they arrive at your site. If you want to track individual vendor conversions, you should add an onclick handler to either the submit button, or link that you are calling a "conversion"
For example:
Your link here
If you are adding the push to a form submit, you might want to have that push happen on the pageload of the success page, rather than the onClick of the submit (otherwise it will track the event, and it might not have actually happened due to form validation errors for example)

Site is showing up as a referrer to its own domain in Google Analytics reports. Why?

I am having two GA reporting problems with a site I manage that I am not sure how to solve:
The site is showing up as a referrer to its own domain in GA reports.
My goal completions (sales conversions on 3rd party off-domain
ecommerce cart) are all showing the site's domain as "source" when I
obviously want to see the true "referers" who are sending traffic
that results in goal completions.
My thoughts on potential reasons why this could happening:
I am using absolute paths for internal links, like this:
<a href="http://example.com/contact.html">
as opposed to
<a href="/contact.html">
Could this be it? Users often do click around internally before they purchase.
Also, on several high traffic pages, I am using javascript history backlinks, like this ::
go back
Lastly, I'm doing a 301 redirect on "add to cart" traffic clicks so that
http://example.com/add_to_cart
redirects to:
http://paymentprocessor.com/ugly_url/cart_page.html
(Although this is an external 3rd party domain, my GA code still fires there)
Any guesses why I am experiencing the issues stated at the top here? ... thank you to all you GA wizards.
UPDATE UPDATE UPDATE
Thanks Eduardo for the great answer.
Thought I might share that now for href text links to 3rd party ecomm site I am tracking events with jquery via class, so my _gaq.push to track both the click event and copy the cookie data over from my site to the third party site looks like this:
$('a.index_addtocart_smallest').click(function(){
_gaq.push(['_trackEvent', 'Outbound Links', 'index_addtocart_smallest', 'buy_click'],['_link', 'ssl.thirdpartyecom.net/order/']);
});
And when I use the form action "add to cart" submit in the HTML look like this:
<form action="http://example.com/add_to_cart" method="post" onsubmit="that=this;_gaq.push(['_trackEvent','Outbound Links','index_big_buy_button', 'buy_click'],['_linkByPost', this]);setTimeout(function() { that.submit() }, 100);return false;">
... to track the event, and post the existing cookie to third party server, while adding a delay to the click to make sure it is captured by GA.
In my case I am using the asynchronous syntax for Tracking Between a Domain and a Sub-Directory on Another Domain: https://developers.google.com/analytics/devguides/collection/gajs/gaTrackingSite#domainAndSubDirectory
In your case it's very clear that the problem is with the cart. When you redirect the user to your cart domain he lands on a new domain and lose access to the cookies that he was using on your site. Because GA needs to create a new set of cookies on the cart site it also creates a new visitor id and a new visit, that visit will be a self referral because that's where the visitor is coming from from GA point of view.
Google Analytics keeps state on cookies, __utm*. So when changing domains we need to copy the cookies from the domain you are currently in to the domain you are moving to. The google analytics API offers some methods to implement this. This is often known as "cross-domain tracking" or "multiple domain tracking". Google Analytics documentation offers a good explanation on how to implement it. You can also search Stack Overflow for several questions related to cross-domain tracking, people seem to have a hard time getting it right.
You are free to use absolute or relative links, it makes no difference for Google Analytics at all.
Javascript redirects are usually ok. Even though there are cases where they certainly make things a little bit more difficult your use case of a back button is fine and should not be causing any problems at all. Of course if the javascript redirect changes the domain you are in you are back to the same issue and needs to implement cross-domain tracking.
Sometimes internal referrers are legitimate. One example of legit self referrals: When a user visits a page on your site and stay there for over 30 min, then navigates to a second page. In that case after the 30 minutes the visit expires and when he navigates to that second page a new visit is created. This new visit will be a self referral and the second page will be considered a landing page. That might seem odd at first, but this is a self referral and it's usually fine.

Google Virtual Pageview Setup

I need some help with the setup of tracking virtual clicks on a submit button. What I need to do is get the referring site, which Google already tracks, and then track if they click on the button. I have setup an onclick for the submit button and setup a goal in Analytics but it is not tracking. I do have the code in place for Analytics in my header to track pageviews.
So what I am trying to do right now with my goal is to track a referring website and then track who clicks on the button. The virtual view I am using for the click is:
onclick="pageTracker._trackPageview('/Orders/Subscription');"
Thank you for any help in getting this setup working. I am still working on learning analytics.
If you want to ...get the referring site, which Google already tracks at the time the user clicks the submit button, you will have to read the cookies (the _utmz in this case) that GA sets and extract it from there.
Referral data can be obtained from the reports in GA, but if you want it at the time of submit, you'll have to get it from the cookies. Plain vanilla javascript can do this for you, just google it. Or, use whatever language your pages are written in to extract the data from the cookie (PHP and many others have this capability).
Regarding tracking the virtual page view, if the user can submit your form by hitting the enter key, then onclick is not desirable. onsubmit in the form tag would be better.
If it is still not recording for you, make sure your goal steps are entered into GA correctly (it's quite common to mess this up and GA is not forgiving to even the slightest error) and that you are using the traditional tracking snippet in the head of your document because your example is in the traditional tracking format. You should not mix async and traditional snippets.
To check if GA is even tracking your virtual page, go to the Content, Top Content report and filter by your virtual page. If it's in there, then it's your goal tracking set up. If it's not in there, it's your virtual page tracking on the form itself.
HTH.

Resources