Automated Testing of Web Analytics with CasperJS
Lukáš Čech @cataLuc Male human (36) Internet (20) Etnetera (11) Analytics (8) Father (4) MC Organizer (3) Double father (2) *) as of 24.3.2018
Why should I bother? Because developers tend to... ...misunderstand our requirements ...break things*) *) 80% time debugging, 20% time creating bugs
Prerequisites Python 2.6+ PhantomJS 1.9.1+ (or SlimmerJS) Environment Variables (PATH) Node JS/NPM CasperJS
Level: Beginner
What do we test? Existence of Data Layer Attribute Values on Page Load
Level: Intermediate
What do we test? Simulation of User Behavior Updated Attribute Values after Events
Level: Advanced
What do we test? Correct Query Parameter values in the respective Analytics Beacons
Side-effects and Tips
Don’t corrupt your data Google Analytics Bot Filtering Applies
Get through Basic Auth on pre-PROD casper.start(); casper.setHttpAuth('username', 'password'); casper.thenOpen('https://...', function() {...
Bypass Bot Detection casper.options.viewportSize={width: 1920, height: 1080}; casper.start(); casper.userAgent('Mozilla/5.0 ...'); casper.thenOpen('https://...', { method: 'get', headers: { 'X-Good-Bot': 'I promise' }}, function() {
What’s next Using this within Continuous Integration Automate test definition from the documentation
Start Testing Today! Tomorrow! Soon! ...and follow me here @cataLuc

Automated testing with CasperJS