Hello There!

Lorem ipsum dolor sit amet, consectetur adipiscing elit,

 About Ravi Pathak

Ravi is the co-founder of Tatvic and expert at managing different web analytics tools. Ravi actively works on conversion optimization projects to improve conversion rate and test newer hypothesis with e-commerce companies.

Google Analytics Worldpay Ecommerce Tracking

Google Analytics Ecommerce tracking for Worldpay

Tracking worldpay transaction with Google Analytics & getting ecommerce data in most accurate manner is amongst one of the challenging project that we executed for one of our clients recently. I wanted this blog post to address what we all did to capture most accurate Google Analytics data possible into worldpay.

Several issues need to be addressed before proper e commerce tracking can be executed.

Here is the design how worldpay works:

Worldpay doesnt allow javascript to be executed on their domains. So you cannot post any Google analytics code on green boxes as describe above. So technically, nothing can be tracked post step no.1 as described above.

To make this tracking work, several things needs to happen.

  1. We need a thank you page after worldpay transaction finishes which is on a domain where javascript can be executed. That is, we need to have one more step after (3) occurs which pushes user to move from (3) to a new page. That is the page where we can place Google analytics ecommerce tracking and track the value of transaction. Let’s call it step no.(4)
  2. More importantly, we need to pass all the Google analytics cookies to this thank you page ,so that the ecommerce code that gets executed on step no.4 attributes the transaction to original cookies that were present on product page or step (1).

So essentially we need to have a page at step (3) that provides a button on Worldpay that says click here to finish the transaction. I will come back later as to what other things that button needs to do.

So till now , by having that button “click now to finish the transaction” ,one problem is solved so that we have one page where we can put GA code & execute the addtrans etc functions of Google Analytics.

Lets focus now on how we can pass on same cookies that existed on step (1) to step (4). Normal google analytics functions of linkbypage will not work as they can only work if the next page can fire Google Analytics.

This is where this gets really innovative.

You can get all the required cookies one by one. But, there is a simple way to get all GA cookies required at once. By using the method, pageTracker._getLinkerUrl of Google Analytics, which will give you all the cookies required along with the URL.

Now, there is a concept of hidden variable in Worldpay. Hidden variables can pass different values like price, currency, order type etc. You can create a new hidden variable and pass the Google Analytics cookies into these hidden variable.

Generally, the RBS World Pay form (where the RBS World Pay button is located and from where the users goes to RBS World Pay site for payment) looks like the following:

<form action="https://select.worldpay.com/wcc/transaction" method="post">
	<input type="hidden" name="cartId" value="Cart ID">
	<input type="hidden" name="desc" value="Product Desc">
	<input type="hidden" name="currency" value="GBP">
	<input type="hidden" name="amount" value="XX.XX">
	<input type="hidden" name="instId" value=137379>
	<input type="hidden" name="lang" value="en">
	<input type="hidden" name="subst" value="yes">
	<input type="submit" value="Order by credit/debit card" name="submit">
</form>

There are some changes that you need to make for this to work:

  1. The form needs to be given a name, if one is not present. This can be done by adding name=”worldpay” in the form element.
  2. We also need to have one custom variable defined in RBS World Pay system which will have the value of the cookies required, that can be accessed in Thank you page. Here, the defined custom variable is MC_gacookie. In this particular example, we also have one more defined custom variable MC_analytics which will have account id. This is required only when pages with different profile ids leads to same Thank you page.

With these changes, the above code of RBS world pay on product page will look like the following:

<form action="https://select.worldpay.com/wcc/transaction" method="post"> 
	<input name="cartId" type="hidden" value="Cart ID" />
	<input name="desc" type="hidden" value="Product Desc" />
	<input name="currency" type="hidden" value="GBP" />
	<input name="amount" type="hidden" value="XX.XX" />
	<input name="instId" type="hidden" value="”XXXXXX”" />
	<input name="lang" type="hidden" value="en" />
	<input name="subst" type="hidden" value="yes" />
	<input name="MC_analytics" type="hidden" value="XX-XXXXXX-X" />
	<input name="MC_gacookie" type="hidden" />
	<input name="submit" type="submit" value="Order by credit/debit card" />
</form>

Now, let us see what extra statements that we need to add to the normal GA tracking script on product page (or step: 1) that is generally placed at the end of the page.

The modified GA tracking script looks like the following:

<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
try {
	var pageTracker = _gat._getTracker("UA-XXXXX-Y");
	pageTracker._setDomainName("none");
	pageTracker._setAllowLinker(true);
	pageTracker._setAllowHash(false);
	pageTracker._trackPageview();
	var save_url = pageTracker._getLinkerUrl("www.abc.com");
	var aPosition = save_url.indexOf("?");
	save_url = save_url.substring(aPosition + 1);
	worldpay.MC_gacookie.value = save_url;
} catch(err) {}
</script>

These additional statements are aimed to accomplish the task of saving all the required cookies as the value of the custom variable MC_gacookie that is created above.

Now, we need to store this value in a custom variable, MC_gacookie, which is specially created for this purpose. This value is accessed in the format <formname>.<variablename>.value and to this, we assign the value of required substring, save_url, obtained above. In the above example, formname is worldpay and variablename is MC_gacookie.

So by doing above, we have been able to pass the cookie values to a specific custom variable to be passed into worldpay without the need of javascript.

What is needed now is what to be done on page 3 (in worldpay’s language its called callback page). In This call back page (step: 3), we get all the variables through post methods. Just to remind that this page (or call back page or step 3) is generally a purchase completion page. Here we are changing to just have a button which says “click here to complete the transaction” button. This call back page resides on website’s server however it gets executed on worldpay.

Now this button needs to pass the values of Google analytics cookies that we had been able to pass it via a custom variable (in our example MC_gacookie) in worldpay. If you use PHP, you can use following code to get that custom variable and form a query string (don’t confuse this with GA custom variable- this is WP custom variable).

<?php $parameter = 'MC_gacookie';
if($_REQUEST[$parameter])
{
    $query="";
    //Get all existing parameters
    foreach($_REQUEST as $k => $v){
     if($k != $parameter) {
     $query=$query.$k."=".$v."&";
        }
        else
		{
        $query=$query.$v."&";
        }
    }
    $query=substr($query, 0, -1);
?>

Here $currentpage is the complete path of the thank you page. So, $currentpage can take value like http://yourwebsite.com/thankyou.html
Note: You will get a warning message when you click on the button above.
So what you have done till now is, you have passed the GA cookies till step 3 and have it as a query parameter when user clicks on the button.
The thank you page will now have the following GA e-commerce code.

<script>
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));

<script>
var pageTracker = _gat._getTracker("UA-XXXXXX-XX"); //This needs to be set if this value is different
pageTracker._setDomainName("none")
pageTracker._setAllowLinker(true);
pageTracker._setAllowHash(false);
pageTracker._trackPageview();
pageTracker._addTrans(
	"", // order ID - required
	"", // affiliation or store name
	"", // total - required
	"", // tax
	"", // shipping
	"", // city
	"", // state or province
	"" // country
);
pageTracker._addItem(
	"", // order ID - required
	"", // SKU code (stock keeping unit)
	">?=$_GET['item_name']?>", // product name
	"", // category or variation
	"", // unit price - required
	"" // quantity - required
);
pageTracker._trackTrans();
</script>

 

How to Refresh with Tatvic Google Analytics Excel Plugin

tatvic-google-analytics-excel-plugin-screen-refresh

While we had an overwhelming response to our Google Analytics Excel Plugin, we realized that it might be worth explaining in detail the core features of the plug-in.

So for this post, I have decided to explain how to use our auto-refresh feature using cell references from an Excel sheet. Below are the steps that users can take in order to update their dashboards automatically by changing input criteria. You would require to log in before you execute these steps.

1.       Insert required from and To dates in the excel sheet in two different cells as shown in the image below.

2.       Click on Excel Icon in the client next to the “From” date

3.       Select the cell where the “from” date is inserted(for example it is B3) & Click “OK”. In the example below, it is B3.

4.       Similar to #4 select the “To” date by clicking on the excel icon next to the “To” date

5.       Select the cell within excel where you have the “To” date provided. In the example below it is B4.

6.       Select required parameters like data granularity (breakdown by)

7.       Select the appropriate metrics & dimension that is required for analysis. In the example below, for the sake of simplicity, I have requested no. of visits by visitor type.

Once, the above request executes you will see the output as shown below.

The above table starting from cell D4 provides you visits by visitor type for the month of July-09.

Now if you need the same data for Aug-09 or for any other dates, you can just change the date in the excel sheet (aka B3 & B4) and click on refresh to get updated data in your excel sheet directly.

For .e.g.

As shown below once you change the dates in cells B3 & B4, and click on refresh, the Tatvic Google Analytics Plugin will automatically, extract the data from your Google Analytics account for the updated dates based on the value in cells B3 & B4. This will result in updated numbers for the visitor type table as shown below. Notice that in July, there were, 22,240 visits by new visitors vs. in August about 20,762 visits by new visitors!

How do you pass your online discounts

Recently, one of our e-commerce client requested that he would want to pass on few discounts in order to increase the revenue. We didn’t really had lot of time to analyze the market and plan what to offer and he already had something to offer in his mind. Then she was going to just put it on its website and doh done !!

at 1 AM morning here in India , we requested client to wait for 2 more hours before putting the offer into production. We just looked at google analytics for first hour, luckily we had set up google analytics very nicely for them. We found that

  1. The visits that coverts were mostly from returning visitors.
  2. The visits that converts were mostly between 2 PM to 10 PM on the local time.

That’s it pretty simple with google analytics and its advance segment features. So what happened after-wards ? See here is what we got. really nothing fancy , just a 5 grader !

We requested client to shed the offer budget by 30% and put it in buying some more traffic from Pay per click campaigns. We also wrote a quick piece of code which will only display offers/discounts between these hours and that’s it. It did not take really long.

The entire work got done at about 6 AM here in Bangalore and boh we were good. About 4 hours.

What are the results ??

  1. The campaigns brought about 10% more visits to the website
  2. The conversion rate dipped a little but it was offset by extra visits that we bought from PPC
  3. The net profit from this entire operation was about double the similar offer that they had ran earlier. In quantity it matched about $3500 of net benefit in 4 hours !! Whoppa !!

Thats the game ! more than money , it gives immense pleasure to see such results.

Guys, if you are really providing any discounts and offers please do check for the such things.Because, you do have consumers in the market who are willing to pay for your products/services happily. You only want to offer discounts to the guys who are sitting on the sidelines.

If it takes 4 hours to us to get such a great results, even if it takes about a day to do it, I guess its more than worth it.

Have you done such analysis in past ? can you try now ?

Bot Icon
Bot Icon

Tatvic Bot

Explore About Tatvic and Services