lay groundwork for ping tracking on the the client side
cleanup frontend js to IIFE for better encapsulation