New Relic is pretty great if you want a hosted solution.
If you want to roll your own I'd suggest starting with something like yahoos boomerang [0]. It gathers metrics on the client and sends them to your server over a beacon/pixel endpoint. I also really like this bookmarklet [1] to visualize the window.performance object.
[0] https://github.com/yahoo/boomerang [1] http://kaaes.github.io/timing/