Contact us

Measuring footfall with Google Analytics

Tracking in-store footfall for retailers with GA

news and insights

As marketing engineers, we were incredibly excited when Google introduced the Measurement Protocol in their release of Universal Analytics a few years ago. This lets developers send raw user interaction data straight to Google Analytics, so it enables measurement in new environments, including offline. This makes it perfect for tracking in-store footfall!



One of our clients challenged us to find a way to measure in-person visits to their brick and mortar store. Naturally the Measurement Protocol sprang to mind, but while there are a lot of custom footfall tracking technologies available, these tend to be quite costly. After a workshop to brainstorm some ideas, we decided to engineer a custom solution.

We settled on a PIR (passive infrared) sensor. These change voltage when they detect movement, so, in theory, if we set one up at the entrance of the store, it would fire every time someone came in.


The Measurement Protocol allows any “hits” like this to be sent to Google Analytics (GA) from any internet-enabled device. Of course, the PIR on its own isn’t connected. To get it online, we used a Raspberry Pi. By connecting the PIR sensor to its GPIO (General Purpose Input / Output) header, we could then write some code that would send a “hit” to GA whenever movement was detected.

We used Python for this – a very powerful language, and already part of the stack provided with the Linux distribution which comes with a Raspberry Pi.

Here’s the Raspberry Pi with the PIR sensor attached.

For installation in the client’s store, the PIR sensor needed a clear view of the front door and the Raspberry Pi needed to be plugged in for power. Fortunately, there was an in-store television with a USB port and, as it was on the mezzanine above the main store entrance, it gave the PIR a good view of the doors. Here’s the view it had, and the Raspberry Pi attached to the store TV.


Once we were online, data began flowing almost instantaneously into GA.

We created a very simple dashboard to show the number of in-store visits (recorded as pageviews). Unfortunately, the Dashboard feature in GA was a bit limited at the time, but was fine as a working proof of concept. With platforms like Data Studio 360, Analytics Canvas, Tableau and our own Artefact Intelligence Centre, it would be easy to create a better dashboard comparing visit performance by hour and day.


Our biggest takeaway from this was to bring an independent power supply! As we were drawing power from the store TV, it needed to be on all the time. However, the store’s staff quite often forgot to turn it on when opening or turned it off partway through the day, which meant no data came through. We’re in the process of giving the Raspberry Pi its own (dedicated) power supply.

Google Analytics also allows us to define custom dimensions and metrics, so we’re going to introduce a Store Visit metric and pass the date and time from the Raspberry Pi across to GA. In addition, because the store has two floors, we’ll also introduce a second Raspberry Pi to the upper floor so we can pass Floor as another dimension and see what percentage of visitors actually go upstairs. We may also introduce a calculated metric to halve the number of visits, as the PIR detects people leaving as well as entering the store.

The next iteration, therefore, would be exciting but quite difficult: switching from the PIR to a camera to detect individuals, possibly using Google’s Cloud Vision API. This would stop double counting and potentially (depending upon how complicated or simple we wanted to get) allow us to use the hash of an individual’s face somehow as a User or Client ID. This in turn would (on paper at least) lead to an understanding of how many times the same person visits a store.


If you’d like to learn more about our data offering, give us a call on +44 (0)207 607 5650 for a no-obligation coffee and chat. How could our unique brand of data insights thinking benefit your business?