Archive for July, 2009

How to use Google Analytics Tracking through RBS WorldPay

Monday, July 27th, 2009

A very technical post this time, so that others with the same problem don’t have to struggle as hard as we did:

What’s the Problem?

We encountered that Google Analytics shows the wrong referrer information when tracking through the payment pages of RBS WorldPay (Business Gateway). The payment pages are served by WorldPay, and Google Analytics shows WorldPay as the referrer, instead of the original referrer (e.g. an organic google search or an Adwords ad). The original referral/visitor information is lost. This in particular annoying for the tracking of e-commerce transactions on the payment response pages, which will all show WorldPay as the referrer.

All code snippets are in PHP and JavaScript. It shouldn’t be a problem to translate the snippets into other languages. This solution should also work with the announced changes to the WorldPay payment pages (which will forbid any JavaScript).

[Jump to solution summary]

What doesn’t work and why?

The Analytics help explains that you should add linker methods to your Analytics code for cross domain tracking between different servers (your server and the WorldPay server in this case):

var pageTracker = _gat._getTracker("UA-12345-1");
pageTracker._setDomainName("none")
pageTracker._setAllowLinker(true);

on the second (linked) website and

onSubmit="pageTracker._linkByPost(‘https://select.wp3.rbsworldpay.com/wcc/purchase’);"

or

<a href="https://select.wp3.rbsworldpay.com/wcc/purchase" onclick="pageTracker._link(this.href); return false;">go to WorldPay</a>

on the first (linking) website.

These linker methods represent a workaround for the cookie based tracking that Analytics uses by default. Since a cookie can only be accessed by the web server placing the cookie, another website cannot use the same cookie to ‘continue’ tracking a user coming from a different server. The linker methods modify the target-URL of the link. On the target website, they also instruct Analytics to use the GET parameters (from the linked URL) instead of the (non-existing) cookie to retrieve the referral information, and to place a cookie with that information for the new web server. Hence, the linker methods ‘copy’ the cookie from the first (linking) server to the second (linked) server.

However, since you are reading this, you probably know already that this solution does NOT work with WorldPay.

We believe it is due to the internal re-directions on the WorldPay pages: WorldPay automatically redirects the user through different subdomains on their servers during the payment process, and there is no way to evoke the above mentioned linker methods for these redirects.

In addition, with the announced changes to the WorldPay payment pages (which will forbid any JavaScript), tracking on the payment pages wouldn’t work any longer anyway.

So what’s the solution?

The answer is to bypass tracking on the WorldPay pages altogether, and to track only on the payment response page . The payment response page is served by WorldPay, but you can instruct WorldPay to fetch the code from your server (WorldPay only asks you to include a special banner-tag, so that they can show some payment related information). While you cannot track the correct referrer information on the payment response page directly (because it is served by WorldPay, and thus doesn’t have access to the original cookie from your server with the referrer information), you can include an iframe from your server on the payment response pages . In this iframe (which may be hidden), you can include your tracking code for page tracking and for e-commerce transactions. The iframe is served from your server, so it has access to the original cookie and can read the original (and correct) referrer information. In the example below, we pass on our own order ID to track it within the track-transaction.php file.

On the payment response page, include:

<iframe id="wp_frame" src="www.your-server.com/track-transaction.php?id=<?php echo $order_id; ?>" style="border:none; display:none"></iframe>

That solves the problem. Well, almost. It solves the problem for all browsers except for… you guessed it… Internet Explorer (6 and higher). Internet Explorer with standard privacy settings does not accept third-party cookies. And your iframe is considered third-party content, because it is not served by the same host as the payment response page.

While pageviews and transactions are tracked with the correct referrer in FireFox, Chrome, Opera, and the other browsers, the pageview and transaction is not tracked for visitors using Internet Explorer.

A bit of internet research will tell you to include a P3P privacy policy using

header(‘P3P: CP=\"CAO PSA OUR\"’);

in the beginning of your code to overcome this problem. Placing this code on the page that serves the iframe content will instruct Internet Explorer to trust your site, and hence allow access to the cookie.

When you include the privacy policy in your code, the pageview and transaction tracking actually takes place, and you can see it in Google Analytics. But… You are back at square one (at least for IE), because it shows the WorldPay server as the referrer. For some unknown reason, the Analytics code is not able to read the correct referrer information from the cookie, and replaces it with a new referrer, just as if there hadn’t been any cookie at all.

To overcome this you have to use the linker methods mentioned above: On the page that links to the WorldPay payment pages (i.e., your cart or checkout page), you need to invoke the _getLinkerUrl method to prepare the correct URL:

var save_url=pageTracker._getLinkerUrl("www.your-server.com/track-transaction.php?order_id=");

Save that URL somewhere on your server (e.g. in the orders table of your database) or pass it through WorldPay using their hidden fields. Then, upon reaching the payment response page, retrieve this information and use it as the URL for the iframe:

<iframe id="wp_frame" src="<?php echo $save_url ; ?>" style="border:none; display:none"></iframe>

Finally, on the page containing the iframe content, you need to include the following statement to instruct Google Analytics to read the referrer from the GET parameters in the URL instead of from the cookie:

var pageTracker = _gat._getTracker("UA-12345-1");
pageTracker._setAllowLinker(true);
pageTracker._trackPageview();

In addition, you also need to include the P3P privacy policy as mentioned above, because Analytics still needs to write the cookie back to the system.

And that’s it. A small step for mankind…

What it doesn’t do

The mentioned solution does NOT track on the WorldPay pages itself. It merely enables you to link the tracking before and after a user visits the WorldPay pages, so that you get the original referrer information for e-commerce transaction on the payment response pages. With the announced changes on the WorldPay payment pages (which will forbid all JavaScript), tracking wouldn’t be possible on these pages anyway. If you really need to track that a user has visited the WorldPay pages, you might try using an additional iframe in the header or footer of these pages, or calling an Ajax request on your own server upon linking to WorldPay. We haven’t tried that, though.

Solution Summary

Here is a page-by-page summary for those who don’t care how and why it works.

1) On your checkout page (the page that links to WorldPay, e.g. www.your-domain.com/cart.php or www.your-domain.com/checkout.php)

Execute the following statement just before transferring to WorldPay:

var save_url=pageTracker._getLinkerUrl("www.your-server.com/track-transaction.php?order_id=");

Save the "save_url" variable in your database or pass it through WorldPay’s hidden field. You need to access it on the payment response page.

2) On the payment response page (served by WorldPay, but fetched from your server)

Somewhere in the bottom, add:

<iframe id="wp_frame" src="<?php echo $save_url ; ?>" style="border:none; display:none"></iframe>

where $save_url is the URL string created using _getLinkerUrl in step 1.

3) In the iframe content page (track-transaction.php)

a) Add a P3P policy:

<?php
session_start();
header(‘P3P: CP=\"CAO PSA OUR\"’);

(click here for examples in other programming languages)

b) Add the _setAllowLinker method to your Google Analytics code:

var pageTracker = _gat._getTracker("UA-12345-1");
pageTracker._setAllowLinker(true);
pageTracker._trackPageview();

and track the transaction using the _addTrans, _addItem and _trackTrans methods as explained in the Google Analytics help.

That’s it. Cheers!

Press Release: GuideGecko Unveils Preview Functionality for Travel Guides

Wednesday, July 1st, 2009

GuideGecko Unveils Preview Functionality for Travel Guides

Indie guides for trips with a twist can now be explored before making a purchase

Singapore, 01 July 2009 – GuideGecko, the innovative online store and publishing platform for travel guides, today unveils its new guide preview functionality. Guide previews allow consumers to look inside independent guidebooks before making a purchase. Previews for the first independent guides are available immediately on www.GuideGecko.com.

Independent guides offer specialized advice that often cannot be found in mainstream series such as Insight Guides or Lonely Planet. The new preview functionality allows customers to browse through hard-to-find titles to ensure that the guidebooks match their needs and expectations before making a purchase.

“Previews are extremely helpful, especially for highly specialized independent guides. Only when you browse through you can find out if a guidebook covers all the topics you are looking for with the right level of detail. Our preview functionality allows you to do exactly this – all online, from the comfort of your home,” says Daniel Quadt, Founder and Managing Director of GuideGecko.

Only three months after its launch, GuideGecko already offers more than 50 independent travel guides to destinations all around the world, from ‘Diving in the Caribbean’ and ‘Sydney on Public Transit’ to ‘Vegetarian Food in Singapore’ and ‘Passing the Bar Examinations in Pattaya’. Some guides offer more than 40 pages as a preview.

“Previews are a perfect marketing tool for our independent authors, who are now able to show the high quality of their work more easily. Therefore, previews offer a win-win situation for customers and authors,” says Quadt.

GuideGecko currently offers more than 2100 guides in total, including all major guidebook series such as Lonely Planet, Rough Guides and Insight Guides. GuideGecko continues to invite budding authors to upload and publish their own guides and to offer as many preview pages as they like. Independent guides can range from short booklets to thick books and cover any travel, lifestyle or entertainment topic. Independent authors can publish and sell their guides through GuideGecko’s online publishing platform at www.guidegecko.com/publish, and GuideGecko makes such guides available for download and as printed books or booklets. Independent guides and previews are accessible at www.GuideGecko.com.

XXX

About GuideGecko

GuideGecko is part online shop and part publishing platform for travel, lifestyle and entertainment guides. GuideGecko currently offers more than 2100 guides on 169 countries and 270 cities and regions around the world. All well-known series are available, including Lonely Planet, Rough Guides and Insight Guides, along with a large variety of less conventional titles such as Hedonist’s Guides and Trailblazer, amongst many others.

Budding authors are invited to publish and sell their own guides on www.GuideGecko.com, and GuideGecko makes such guides available as PDF downloads and as printed books/booklets. Publishing is free and authors earn 50-75% on every copy sold.

All guides on one site, all at very low prices. That’s GuideGecko.

For more information, please visit www.GuideGecko.com. For photos, logos and screenshots, please visit www.GuideGecko.com/media.

XXX

For media enquiries, please contact:

Daniel Quadt
Email: media_[at]_guidegecko.com

Telephone: +65 94555974