Technology entrepreneur, web analytics specialist, Internet enthusiasts. I also like movies, computer games, history and other interesting stuff. I was born in Guangzhou China and I live in Sydney Australia now.

Migrate Your Google Analytics to Google Tag Manager Seamlessly with ga2gtm

If you have custom Google Analytics tracking code on your website, migrating the tracking to Google Tag Manager could be tricky because:

  1. After you replace the Google Analytics base code with the Google Tag Manager code, the custom tracking code on the web pages could cause Javascript errors because either _gaq or ga is undefined.
  2. You lose the tracking features provided by those custom tracking code.

So, one of the tasks in the migration work is to find out all the custom Google Analytics code snippets and replace them with the Google Tag Manager dataLayer code standard. Well, if you have all the previous implementation documents, and your developers have the time to deal with the changes, that shouldn’t be a problem. But things are not always that ideal.

ga2gtm is a project I created to address this issue. Basically what it does is to trigger the dataLayer code from the existing Google Analytics code, so that you don’t have to find them and replace them. All you need to do is to remove the Google Analytics base code, put the Google Tag Manager code and the ga2gtm code in. ga2gtm will convert the existing virtual pageview tracking, event tracking, social sharing tracking and eCommerce tracking into dataLayer format. Then you can pick them up in Google Tag Manager and do whatever you need to do with it. Installation is super simple, just one line of code to reference the ga2gtm Javascript file.

ga2gtm is an open source project licensed under MIT agreement. You can get it from its github repository for free here:

Here is the installation instructions:


Ten Year Anniversary of Arriving to Australia

Last Friday, July 4th, was the ten year anniversary of my first time set foot on Australia. Ten years ago, July 4th 2004, my flight landed in Sydney airport and I knew very little about this country. It was a sunny day just like this July 4th. After ten years, I have settled down in Sydney and I enjoy living here so far. I am glad that I didn’t waist much of the last ten years.


New Setup of My Study Room

Study Room


I spent two weekends to replace the old furnitures in my study room and upgrade the desktop computer. With the new Dell screen (on the right hand side), finally I can have a vertical screen at home just like I do in office. It is very convenient for reading and coding. I still keep the shelf on the left as my standing desk solution.

This is the old setup of my study room:

You can see I kept two good ideas from the old setup: Shelf as standing desk solution, and desk shelf to lift the monitor from the desk for more desk space.


Javascript to Generate a Short Unique ID

Web analytics sometimes requires generating visit ID or visitor ID for storing in the cookies. Below is the code to generate a short enough “unqie” ID for the purpose. It needs to be under 20 characters because Adobe SiteCatalyst / Omniture would only take 20 characters long serialization string. You can control the length by changing the parameter in the slice function.


I am planning to use it with the product code to form a unique serialization string. One thing needs to be clarified is that the string is random, but not really “unique”. However, it is close enough. The chance of having two same strings is pretty small if you keep the string length over 10 characters. Appending a timestamp to string would make it unique.


Hunter Valley Day Trip

We went to Hunter Valley for a day trip. The whether was beautiful today. This is the second time I have been there. The first time I’ve been there was two years ago, and it was raining and cloudy. Everything looks so beautiful under the blue sky today. Here is a photo I took in Audrey Wilkinson Vineyard. The vineyard is on the top of a small hill which overlooks the valley. It is a must go place in Hunter Valley, for the awesome view.


Helicopter ride is $60 per person for 10 minutes, relatively affordable. Many tourists queued for a ride.



Big Screen Dashboards for Web Analytics: Comparison of Ducksboard, Geckoboard, Leftronic and Klipfolio

Recently I wanted to replace the in-house built big screen dashboard because it became very unstable. After some Google searches, I found Ducksboard, Geckoboard and Leftronic. They all offer free trial period, so I signed up and trialed each of them.

The first one I trialed is Leftronic. It seems it is a very popular one. My data source is Google Analytics at this point, but we are going to implement Adobe SiteCatalyst. After authorizing Leftronic to connect to Google Analytics reporting APIs, it is fairly easy to put up some widgets on the dashboards to show today’s visits, revenue, goal completions, etc. But if you are after something more complex, such as mobile visitors vs desktop visitors for the current day, you will have trouble to build it. The wdgets for Google Analytics is very simple, either a line, or a number. There is a map for the visits and visitors. There is always a triangle next to the number to show comparison of the previous period, which of course almost always in red because it is comparing current day to yesterday full day in my case. And I can’t get rid of it.

So I try Geckoboard, which is actually better. The wdgets have more options available when pulling data from Google Analytics. You can even apply segments on the data. But when it comes to line widgets, the interface always put the last number next to the line, which means it is the current hour visitors on my hourly visitors line for the current day. And Ducksboard just doesn’t work. After I built a widget, the widget fails to retrieve data so I stopped waisting time on it.

After trialing Ducksboard, Geckoboard and Leftronic, I would say Geckoboard is the winner. The dashboard interface is nicer, the widgets are more flexible in retrieving data. The map widget is definitly better than the Leftronic map widget too. But, none of them can satisfy my requirements.

Geckoboard Bashboard Screenshot

Thanks to the colleague sitting next to me recommanding Klipfolio after I told him these dashboard tools. I found Klipfolio is very flexible. It allows you to write your own Google Analytics reporting API requests, which means you can get whatever you want from Google Analytics as long as Google Analytics reporting APIs support it. And it also supports Adobe SiteCatalyst APIs, although I am not sure if that works yet. However, you can image it is not as easy to use as the above tools. The idea is you can use the APIs to build data source to pull the data from Google Analytics to a spreadsheet in Klipfolio platform. Then in the widgets, they call them Klips, you can use forumlars to manipulate the data and present them. Since you can use forumlars on the data, you can even build calculated metrics on the Google Analytics data, which is a feature Google still fails to deliver now. The data can be refresh as frequent as every minute, pretty good for close to real-time big screen dashboards if you are using Google Analytics. And it is a good tool to build dashboards can’t be built with Google Analytics built-in widgets. That is the reason at the end of the trial, I decided to go with Klipfolio and now our big screens on the walls are showing the Klipfolio dashboard I built.

Another thing I learn from the trial is that although building big screen dashboards is a fairly simple thing compared to any web analytics project, but it draws a lot of attentions in the office and people are always amused to see how the website is doing. It is a very good way to showcase web analytics and get people interested in web data.

Here are some example dashboards on Klipfolio website:

Klipfolio Dashboard Screenshot

© Copyright 2014, All Rights Reserved