WAUnit is a web analytics regression testing framework I created. It is written in Python and leverages Selenium webdriver and a built-in proxy server to test web analytics implementations.
With WAUnit you can automagically verify your entire web analytics implementation!
Currently, it only supports Google Analytics, but support for other platforms is under way.
How does it work?
I’m going to use the Google Store as an example. When a user clicks the ‘BUY FROM $499.00’ button (marked in red below), an event with the following specifications is fired:
hitType: event
eventAction: Buy Now
eventCategory: Checkout Funnel
eventLabel: nexus_6p
WAUnit is composed of two main components:
a local proxy server based on mitmproxy
one or more unit test scripts
The local proxy is started using a shell command: waunitproxy.
A simple a unit test using Selenium programmatically visits the Nexus 6P page and clicks the ‘Buy from $499.00’ button.
Meanwhile, the local proxy intercepts the web analytics hit.
The unit test connects and compares the proxy hit log with the specification. If the specification matches, the unit test will pass, if not it will fail and provide information on what doesn’t match.
WAUnit allows you to verify web analytics implementations, automatically. Trust in the implementation is invaluable to the success of web analytics.
See a 5 minute video with the complete Google Store example (view full screen)
Installation & Google Store Demo
Install WAUnit using Python package manager or download WAUnit from GitHub
Create a project folder for the sample unit test. We will use it to store the configuration file and the unit tests.
Create a file named: waunit.cfg and save it to your project folder.