Tracking first visits to a website

In the world of marketing and advertising there is always the need to understand what kind of effect the activity is having. After all you only do marketing because you hope it will drive your business forward in some way.

In essence there are only 2 ways to try to understand the effects of advertising:

  1. Micro Level – This specific user saw an ad and then converted 2 days later.
  2. Macro Level – We normally get 100 conversions a week, but when we advertised on TV we achieved 200 conversions in that week. Normally calculated as a result of some regression analysis.

The methodology in this post is a much more granular approach to the macro level analysis of advertising activity.

Web analytics tools such as Google Analytics or Adobe Analytics are very good tools at telling us how many people do what and when, eg our site received 50 visits at 11:53 on Friday 10th August. These tools are not so good at answering such questions as ‘the customer who converted at 18:30 on Saturday 11th August, when was their first visit?

This post will detail how to answer this question. Firstly we are going to need to implement some custom JavaScript code.

JavaScript code to track first visit data on this website. Implemented on all pages of the website.



 

This code leverages the information available to the page via the Document Object Model (or DOM).

For browsers to be able to provide a quality experience to the user, they need access to various data points and to react to that data. Data such as how wide is the browser window can help the browser decide how to display images. For example as a web developer you may want an image to be the full width of the browser no matter how wide the browser is. Allowing the browser to access the data relating to the width of the browser window enables the browser to resize the image so it is always the full width.

For those who are not familiar with the DOM and how it is used by the browser it is worth having a closer look. The browser can have access to an array of data points relating to your browsing session and also about your machine. Examples include browser dimension, current date and time, language and operating system.

In fact browsers are able to pick up such detailed data that there is a tracking framework known as device or browser fingerprinting that can uniquely identify users.

For the use case of recording the details of the first visit we will only make use of 3 of these data points:

  1. Current page URL
  2. Previous page URL
  3. Current time.

The JavaScript code above when deployed on a website will record in a cookie the above details on the first page load, the first time a user visits a website.

Cookies, because of their persistent nature, now make this information accessible at future times.

Where this all ties together is if you have offline activity such as radio or TV activity driving online actions. Presumably the offline activity will drive some people go to the website. This is where the details of their first visit is recorded in the cookie. Eventually some of these people will go on to do a desired business action, such as buy a pair of shoes. It is at this point, at the point of conversion that we can retrieve the first visit data from the cookie and store it alongside the conversion data.

We now have conversion data enriched with details about their first visit. Not only can we now answer questions like ‘after coming to our website for the first time how long does it take someone to convert on average‘ but we can marry this first visit data up with TV or radio activity data and say ‘Our prime time ad aired at 7pm, which resulted in 300 new people to the website in the following 20 minutes. Of these 300 new people to the website 50 converted within the hour, and another 75 converted over the next 3 days‘.

Without the first visit data we would only be able to count those conversions that came in in a close proximity to the ad airing, and not counted those who take longer to pull the trigger. Giving us a fuller picture of what kind of effect the advertising is having.

For a live example of this methodology in action check out the First Visit Data page.

Send a Comment

Your email address will not be published.