In the past two weeks, Jop van Sommeren posted two interesting blogs about multi touch conversion tracking. In short, Google Analytics currently gives you the possibility to view conversion based on the last touch (the last point of entry to your website) and neglects the fact that other sources might have contributed to this conversion. The script published in this article shows that it is possible to add this missing multi touch tracking data to Google Analytics reports by adding a small script to the pages on your website.
Script details
The script you will find as a download below tracks the referrer to your website, which can usually be found with JavaScript in the variable document.referrer. Most code blocks in the script are commented and experienced programmers will probably understand the code within a ten minutes or less. The following paragraph will roughly explain what the script does and might be somewhat difficult to understand for non-programmers (who might be more interested in the results further ahead).
First of all, tracking by the script will only occur if this referrer is present and usable (meaning that it is an external referrer which can be tracked). On the first visit, the referrer is saved as being the ‘first-touch’ and ‘route’, while on subsequent visits the data gets added to route-variable separated by a tilde (~). Please note that there is a 64-byte limit on the variables and that route tracking will only occur when there is still space left to save the data (most likely this space is enough to track three or more referrals in the route). Data is also ordered by name (thus not by the moment of tracking), to ensure grouping of tracking routes. As a nice addition, the script also creates a cookie on the first visit with a UNIX timestamp. This allows the script to track the ‘time-to-conversion’ in a third variable on later visits as you will see in the results below. When added to the website, all tracked data will be added to your Google Analytics report under Visitor > Custom Variables (see the tables below).
Script results
We did a lot of tweaking in the past two weeks to identify various referrers using this script. Because of this, our results will probably differ a bit from the cleaner final results, but they do look promising and will definitely help us to optimize our website. Below you will find the three added tables with a short explanation of the shown results. Please note that I filtered the results using a custom filter, to exclude the buggy data tracked during development. This filter is not required to view these results within your report as the script should now work as intended.
First of all, a table that tracks the ‘first touch’ (the first point of entry to your website) was added. This data is very important as the first touch is most likely the website that informed the visitor about your existence on the web. If a visitor comes back later through an other source and converts, the original report will not show this first touch. Using the table above, we can see that Twitter and Google are two important sources for conversions: our original data showed a conversion rate of only 5.14% for Twitter referrals, but in reality Twitter seems much more valuable as the data shows that it was a source that led to other conversions as well.
The table above shows the new route-tracking table that has been added to Google Analytics. As you can see, fourteen visitors directly requested our website without converting. In addition, some visitors found our website directly and through Facebook; if they would have converted we could see this and we would be able to tell that both these sources might be important for our conversion rate (the original report would only tell you the last source of this conversion, thus either ‘(direct)’ or ‘www.facebook.com’ would be present and not both).
As you can see in the table above, we had various conversions from different kind of users. The image above shows that 60 persons visited our site and five percent of them converted (Goal1 Conversion Rate) within the first hour resulting in a ‘time-to-conversion’ of zero. In addition, various persons visited us again after several hours and some of them also converted (one visitor converted after 37 hours resulting in a 100 percent conversion rate on line 4). Gathering this information for a longer period will show how long the average time to conversion will be for your visitors, giving you a better indication of what you can expect in the future.
Download
Since the script is a bit large to post in the blog, you can download it directly as it is released under the GNU General Public License (GPL). As you can see I named the script Tracert, after the famous tracert command used to trace packet routes on the Internet. In the coming weeks I will most likely publish a second version of the script using MooTools which will reduce the size of the script dramatically (but obviously requires you to include the MooTools library).
Update (28/06/2010): A Mootools variant can now be found here.
Grigoriy
10-02-2011 06:30Nice script. The small question: why do you store first touch time in cookies, why do not you use the GA custom variables engine for this?
Arno Gideonse
12-02-2011 17:39First of all because I did not want the information to show up in my reports in GA. Secondly, the GA custom variables are limited: only five GA custom variables can be handled for one website / user combination and the length of the content is limited.
Marcio Marinho
15-12-2011 11:48Good script! It doesn’t work with Analytics in async mode though.
To make it work with ga.js instead of urchin.js. Just add the following code after the :
var s = document.getE… from Google Analytics,
insert:
var pageTracker;
_gaq.push(function() {
window.pageTracker = _gat._getTrackerByName(); // Gets the default tracker.
var tc = document.createElement(‘script’); tc.type = ‘text/javascript’; tc.async = true;
tc.src = ‘js/tracert.js?lxfr={/Content/ForceRefreshFile}’;
document.getElementsByTagName(‘script’)[0]; s.parentNode.insertBefore(tc, s);
});
This will fix the “pageTracker is not defined error”.
Cheers,
Marcio