Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

Analytics testing

Analytics Testing
  • What is analytics testing?
  • What needs to be tested on analytics testing?
  • How to test analytics calls?
  • How to get and install mitmproxy
  • Bottom line

When we talk about test automation, we have several Testing approaches that should be taken into account, such as UI testing, data testing, performance testing, or, in this case, Analytics testing.

What is analytics testing?

Analytics allows companies to track user interactions in order to understand how consumers behave when they use the applications. For example, if we are selling tickets for sports events, we can track all the actions performed by users on the app and determine why they abandon the cart, or why they choose a specific ticket over other options for example.

Companies use this technique to boost sales and to know what to change to stop losses.

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 call, we need to be able to capture the traffic while using the application, and then to 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 us mitmproxy to capture the traffic while a selenium script is running, and to save it to a file so I could make my assertions afterwards.

Mitmproxy is a console application that can run on any server, and what needs to be done is to point our browser or mobile device 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 an type:

brew install mitmproxy

Download: mitmproxy

Bottom line

Analytics testing 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.

The post Analytics testing appeared first on Relevant Codes.

Share the post

Analytics testing

×

Subscribe to Relevant Codes — A Blog By Anshoo Arora Featuring Articles On Test Automation Tools, Frameworks And Code-design.

Get updates delivered right to your inbox!

Thank you for your subscription

×