What is the most accurate way to track visits?

What is the most accurate and precise way to track visits both bots and user client? I read this doc but I don’t understand. I need to analyze websites that use Javascript and PHP technology. Currently I’m using the default Javascipt track method.

Any suggest?

Can I use both “standard” Javascript method and PHP Api method to track even the search engine bots?