Integrating Google eCommerce Tracking with WorldPay 2014

Google Analytics WorldPAyAs many developers know there have been issues for a long time integrating Google eCommerce or Google Analytics tracking with WorldPay hosted payment solutions.

The problem arises because both of these tracking systems use JavaScript to read the shopper’s cookies, tracking customers from clicking on an ad in AdWords all the way through payment. This JavaScript must be placed on the merchant’s site in order to read the tracking cookies that Google has placed there.

Unlike other payment providers, (SagePay, PayPal etc), WorldPay do not provide a way to return a customer to the merchant site complete with their payment information. Of course WorldPay supports callbacks, but these callbacks are called from WorldPay, not the customer, and therefore the customer cookies are not available to pass to WorldPay as part of the callback. Instead, WorldPay provide a way for merchants to show custom pages on payment completion via their own servers – but these custom pages are called up from WorldPay and sucked into a WorldPay-delivered page. 

These custom pages cannot currently contain JavaScript due to the risk of Cross-Site Scripting (XSS) attacks. It’s a reasonable security precaution but it stimies the use of Google Tracking codes.

Over the years various solutions have been proposed, including showing an iFrame within your response page. These solutions work for a while but WorldPay always seem to shut them down after some time.

As of the time of writing Google eCommerce tracking is not supported via WorldPay and although they say that new payment pages will be available in Q1 2015 which may support such functionality, we are not holding our breaths! Solution: switch to SagePay!