In this chapter, we are going to explore and experiment with an interesting use case of MongoDB: storing website analytics. There are certain features of MongoDB (which we will discuss in this chapter) that make it an excellent choice as a backend for storing web traffic data. We can use MapReduce to process and analyze the data, measure key metrics, and generate reports. We are going to learn how to do all that by adding analytics features into the blog application that we built in Chapter 2, Building your First MongoDB Powered Web App. We will build a logger in PHP that stores HTTP request data. Then we will use MapReduce to process the data and expose certain statistics in a web dashboard. Finally, we will learn how we can leverage the upsert and $inc feature of MongoDB to store page visit counts in real time.
So to sum it up, in this chapter we will:
Discuss why MongoDB is a good choice for storing web analytics
Learn how to implement logging using...