The Most Important Automation Metrics to Track in 2021

Analytics testing

When we talk about test automation, we we usually think about UI automation, but there are other types of testing, such as data, performance, and analytics that can be automated.

What is analytics testing?

Analytics allows companies to track user interactions in order to understand how consumers behave when they use the application.

For example, if we are selling tickets for sports events, we can track all the actions performed by users in the app and determine why they abandon the cart, or why they choose a specific ticket configuration over other options.

Companies use this technique to boost sales, to understand what it’s needed to to stop losses, to see how the users behave and where we need focus our efforts.

What needs to be tested on analytics testing?

Analytics are usually sent behind the scenes when users perform certain actions, often known as CTAs, such as pressing a button, filling a form, clicking a link, etc. An analytic call is a code sent to a server via an API, and for that reason, it’s impossible to capture the analytic message using selenium or other UI automation tool.

How to test analytics calls?

Well, if we want to test analytics calls, we need to be able to capture the traffic in real time, and then parse the traffic in order to search for the analytics call we were expecting. In my experience, I have been working with open-source tools such as mitmproxy to capture the traffic while a selenium script is running, and to save it to a file so the testing team can make the corresponding assertions afterward.

Mitmproxy is a console application that can run on any server, and what needs to be done is to point our browser or mobile devices to it, so everything it’s captured.

The normal automation flow will be a selenium script that performs an end to end test, usually pre-existing test cases that we already have, while the proxy is running and saving all the analytics call using a predefined filter to a file (mitmproxy allows us to create python filters so we can save only those calls matching a certain criteria).

How to get and install mitmproxy

If you want to install mitmproxy and you have a mac, you can use homebrew in order to install the tool, so we just need to open a console and type:

brew install mitmproxy

Download: mitmproxy

What is needed to test analytics?

You will need test automation knowledge and some console/scripting skills:

Bottom line

Analytics testing process is pretty straightforward, we just need to be able to tweak what we already have and to implement some tools like a proxy and some logic to read the logs in order to validate that propper analytics calls are made when we execute an automated test.

Leave a Comment

Scroll to Top