We’ve had a lot of people enrolled in our Google Analytics Quick-Start Courses asking about PayPal. We’ve helped a few of our clients track PayPal e-commerce within Google Analytics, thanks to the Payment Data Transfer function and a bit of scripting on the back-end.

This method has only been tested with Buy Now buttons, and in all fairness, isn’t much more than a hack. There are a couple of drawbacks. Because you cannot tag PayPal pages with the Google Analytics JavaScript, you will not have accurate funnel data for your e-commerce conversion goal. All converting visitors will leave your site (and move to PayPal) before coming back and registering their transaction. This will also result in an artificial hike in your total visits. That being said, it gets PayPal transaction data into Google Analytics, and is also relatively easy for those who are familiar with HTML, scripting, and general web development. Not everyone is going to understand this stuff, and if you find the whole mess a little too much, we’re happy to help out with one of our Google Analytics support plans. Otherwise, read on and learn about how to track your PayPal transactions in Google Analytics.

Payment Data Transfer (PDT)

First things first, you’ll need to enable Payment Data Transfer (PDT) in your PayPal account. This allows you to transfer payment details (the item purchased, the transaction amount, geographical location of buyer, etc.) to your own website domain.

I’ve found that enabling PDT is a bit of a pain, not because it’s difficult but because it’s hard to find the option in PayPal’s interface. Immediately after logging into PayPal, click the Merchant Services tab. On the right of the screen is a list of Key Features for the PayPal Website Payments Standard. Click the ‘View All Features’ link.

Under Backend Integration, toward the bottom of the page, you’ll see the Payment Data Transfer information. Select ‘Set It Up’.

Here, read through the information and enable Auto-Return and PDT. Follow the instructions to get this working for your PayPal account. You’ll need to create a hidden landing page on your site that collects the Payment Data (PayPal offers examples for ASP/VBScript, Cold Fusion, PERL and PHP). We’ll come back to that in just a bit, though.

Next, create your Buy Now buttons as normal. Again, ensure that PDT is enabled for this button and ensure that you have the correct landing page set.

Okay, to review, we currently have PDT enabled for our PayPal account, we have a hidden landing page that collects and stores Payment Data, and we have a Buy It Now button that initiates the whole procedure.

Modify the Landing Page

Now, we need to modify the hidden landing page. Currently, this page grabs payment data from PayPal and that’s it. What we need to do is store that payment information so that we can pass it from the hidden landing page to a second and final receipt page. One way of doing this is with a JavaScript redirect. Be sure, however, that you grab all of the appropriate variables from the PDT and pass it along to the receipt page, either via the query string, cookies, or post variables.

You must not tag the hidden landing page with the Google Analytics JavaScript. We don’t want to count visits to this page. However, you must tag the redirect link to the receipt page with a special parameter called utm_nooverride. We’ve discussed utm_nooverride before. Basically, this tells Google Analytics not to overwrite existing referral data. We don’t want Google Analytics to associate this transaction with PayPal. We want it associated with whatever sent the visitor to our site in the first place. So, be absolutely certain that the link from landing page to receipt page is tagged: http://www.yoursite.com/
thankyouforordering.php?utm_nooverride=1.

Now, we’re at the receipt page. What do we do? Well, you’ll probably want to provide your visitor with a printable receipt, filling in the data with the variables that you passed from PDT and the landing page. Unlike the landing page, your receipt page is tagged with the Google Analytics script.

You’re also going to want to include the hidden Google Analytics e-commerce form, populated with the very same data as in your printable receipt. And you’ll need to call the __utmSetTrans function after this hidden form.

To summarize, here’s what happens when a visitor from AdWords hits your site and makes a purchase:

  1. Enters your site from Google AdWords campaign x, keyword y, etc.
  2. Clicks your Buy Now button and leaves your site.
  3. Fills out the order form at PayPal and submits payment info.
  4. Returns to your hidden landing page with Payment Data provided by PDT, where they are not tracked by Google Analytics, as there is no script on this page.
  5. Redirects (immediately) to the receipt page, along with the utm_nooverride parameter, telling Google Analytics not to override their initial referral information.
  6. Views printable receipt while their hidden Google Analytics e-commerce form is populated and then sent off for processing by the __utmSetTrans function.

It’s a straightforward procedure that involves a little scripting knowledge, but can be set up in an hour or two. It’s certainly a hack, for all the reasons mentioned above, but for what it’s worth, it’s a quick and easy way to get PayPal transactions into Google Analytics.

If this whole procedure is over your head, don’t fret. We’ve done it many times and we’d love to get your PayPal transactions tracking in Google Analytics. Just contact us about one of the many Google Analytics supports plans that we have available.