Have you ever developed a website or platform where you need some sort of “item” impression count to be calculated? If you reading this – I guess you did :).
So one day I decided to develop a some sort of classifieds website and I wanted to track how many times each ad was shown. I was thinking how to easily implement this and make it reusable. At first, I thought about creating my own custom mechanism to log data into an SQL table, then fetching that data and displaying into an administrator dashboard. But wait a minute… I have to write some sort of magical code which handles it very carefully, as I do not want to stress my servers and database. And then BINGO! The idea came to my mind – Google Analytics.
Why did I decide to use it? Well, this tool has a lot of metrics, some of it are just a standard, some – customized. Also, it has a powerful dashboard and, of course, API (as developers like API’s).
OK, let’s back to my case, I want to track every ad shown, what should I do first? I need to create Google Analytics account :), once I have an active GA account I need to include provided snippet into a website.
And now – track all the ads shown! For this, I am using GA events, once an ad is rendered (you can go more advanced for this, maybe a new blog post?) code is firing GA event to inform google servers that particular entry is shown for an end user.
That’s it, now you can go to GA dashboard and check out some generated charts in the events section. As google provides dashboard customization you can choose any other angle to view that data.