Posts tagged with google

... or how to pull data about page visits instead of implementing custom counter

Preface: OK, so you have a website, right? And you are using Google Analytics to track your page views, visitors and so on?(If not you should reconsider to start using it. It is awesome, free and have lost of features as custom segments, map overlay, AdSense integration and many more.)
So you know how many people have visited your each page of your website, the bounce rate, the average time they spend on the page etc. And this data is only for you or for a certain amount whom you have granted access.

Problem: But what happens if one day you decided to show a public statistic about visitors on your website. For example: How many people have opened the "Product X" page?
Of course you can add a custom counter that increases the views each time when the page is open. Developed, tested and deployed in no time. Everyone is happy until one day someones cat took a nap on his keyboard and "accidentally" kept the F5 button pressed for an hour. The result is simple - one of you pages has 100 times more visits than the other. OK, you can fix this with adding cookies, IP tracking etc. But all this is reinventing the wheel. You already have all this data in your Google Analytics, the only thing you have to do is to stretch hand and take it.

Solution: In our case "the hand" will be an HTTP request via the Google Data API. First you will need to install the Python version of the API:

sudoeasy_installgdata

Once you have the API installed you have to build a client and authenticate:

SOURCE_APP_NAME is the name of the application that makes the request. You can set it to anything you like.
After you build the client(2) you must authenticate using your Google account(3-9). If you have both Google and Google APPs account with the same username be sure to provide the correct account type(8).
Now you have authenticated and it is time to build the request. Obviously you want to filter the data according some rules. The easiest way is to use the Data Feed Query Explorer to build your filter and test it and then to port it to the code. Here is an example how to get the data about the page views for specific URL for a single month(remember to update the PROFILE_ID according to your profile).

Final words: As you see it is relatively easy to get the data from Google but remember that this code makes two request to Google each time it is executed. So you will need to cache the result. The GA data is not real-time so you may automate the process to pull the data(if I remember correctly the data is updated once an hour) and store the results at your side which will really improve the speed. Also have in mind that this is just an example how to use the API instead of pulling the data page by page(as show above) you may pull the results for multiple URLs at once and compute the feed to get your data. It is all in your hands.
You have something to add? Cool I am always open to hear(read) you comments and ideas.

As stated in the official Google blog Google will discontinue Wave development(at least as an independent product). I looks like low user interest is the main reason for this decision.

We have to admin that Wave creates a new point of view on the web technologies and it is little sad that this "new wave" meet its end so quickly but I doubt that Google will completely forgot Wave. I am pretty sure that we will see many of the Wave features in the upcomming Google social network(Google Me).

Also the main parts of the code are availabe as open source so I think that there will be a lot of developers who will continue to use and improve Wave features.

...will google finaly place itself on the top of social networks?

Most of the people will say "No". This was the first try of Google to take place in the world of the social networks. Ok, maybe not the first. I have to admit the the first was in the late 2003rd when Google offered to purchase Friendster, but their offer was declined. So they decided to start own project and in 2004th Orkut was launched with the hope that it will dethrone Facebook from the leading position. Although the big interest in the start it didn`t succeed to take the first place(by registered users) and is now on number 7 with 100 milion users. Some people blame Brazilians for overwhelming it and repulsing other members by using not English but Portuguese in social discussions. Since then Orkut is widely used in Brazil and India but not popular in the other countries.
So this was big failure number one(if you can call failure 100 milion users.)

This was the second attempt, this time the "attack" was pointed in the area of short messages. Again it couldn`t reach the size of its main competitor Twitter.

Google Me

Digg founder Kevin Rose, posted on Twitter the rumour that Google are going to intriduce a Facebook competitor. SF weekly posted an article that this is true and Google have already allocated many engineers to this project.

The only thing left to us is to wait and see will Google finaly succeed to take the throne of social networks king.