Missing Transactions? Improve accuracy of Paypal and GA Ecommerce integration
checkout the end of post for an easier method. 🙂
Usually when we need to implement google analytics for a site using 3rd party hosting shopping cart it’s simple enough. The general method to achieve this is to do cross-domain tracking. This requires a little code change to tell google analytics to send cookie information of the visitor to the checkout domain.
Because Paypal does not allow you to add analytics tracking to its pages we can’t use cross domain tracking, instead we have to wait for a user to come back to the site and then trigger a sale.
There’s a simple method using Paypal PDT to do this once the user completes the purchase through PayPal and returns to the site order information from PayPal is retrieved, ecommerce tracking is triggered and sales information is sent to Google. In about 85-90% of cases, user returns to the site successfully and we can trigger a transaction. But those 10-15 % of times a user closes the page after completing the order, is where the trouble lies. That’s a lot of information about customers getting lost. This is exactly the problem we faced recently.
To get around this, we built an alternate 100% accurate tool using Paypal IPN API, we can use it to trigger a sale regardless of whether a customer comes back to the site or not.
To make this work we started with identifying a user when they leave for PayPal to make a purchase. This is essential because we need to be able to connect a user’s initial behavior [where they came from, what they clicked etc] with the final purchase. Because the user may or may not come back its essential to have a way to identify users.
Second, we configured IPN to send alerts whenever a transaction was completed. Using the information from the transaction and the unique identifier we configured in the first we had all the data we needed to tell Google Analytics about the order.
Now all we needed to send this information to GA. That was done using a PHP based version of GA, that allowed us to send all the data to google analytics as they came in.
The end result is a completely accurate google analytics ecommerce integration with Paypal. For an added bonus this can also be used to process refunds 🙂 and even recurring orders.
If the site is new and just starting out the first solution using PDT should be enough, but for a big enough 10-15% of Paypal orders means losing out on a lot of insights and that’s where something like this would come in very handy.
Ps. We ended up writing a very neat tool in a recent hackathon that could be integrated into almost any site or even work with other 3rd party solutions like Clickbank, Worldpay. It turned out to be a fun exercise helping us quickly master Paypal ipn, curse Paypal’s documentation and use some server-side google analytics tools.
Need help with enhanced ecommerce tracking?
check out how we can help you see actions in your data.