Modern IoT analytics are computational and data intensive. Existing analytics are mostly hosted in cloud data centers, and may suffer from high latency, network congestion, and privacy issues. In this paper, we design, implement, and evaluate a fog computing platform that runs analytics in a distributed way on multiple devices, including IoT devices, edge servers, and data-center servers. We focus on the core optimization problem: making deployment decisions to maximize the number of satisfied IoT analytics. We carefully formulate the deployment problem and design an efficient algorithm, named SSE, to solve it. Moreover, we conduct a detailed measurement study to derive system models of the IoT analytics based on diverse QoS levels and heterogeneous devices to facilitate the optimal deployment decisions. We implement a testbed to conduct experiments, which show that the system models achieve reasonably good accuracy. More importantly, 100% of the deployed IoT analytics satisfy the QoS targets. We also conduct extensive simulations for larger-scale scenarios. The simulation results reveal that our SSE algorithm outperforms a state-of-the-art algorithm by up to 89.4% and 168.3% in terms of the number of satisfied IoT analytics and active devices. In addition, our SSE algorithm reduces CPU, RAM, and network resource consumptions by 18.4%, 12.7%, and 898.3%, respectively, and terminates in polynomial time.