Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use Google Analytics for data to display on our webpage?

On some of our pages, we display some statistics like number of times that page has been viewed today, number of times it's been viewed the past week, etc. Additionally, we have an overall statistics page where we list the pages, in order, that have been viewed the most.

Today, we just insert these pageviews and event counts into our database as they happen. We also send them to Google Analytics via normal page tracking and their API. Ideally, instead of querying our database for these stats to display on our webpages, we just query Google Analytics' API. Google Analytics does a FAR better job figuring out who the real uniques are and avoids counting people who artificially inflate their pageview counts (we allow people to create pages on our site).

So the question is if it's possible to use Google Analytics' API for updating the statistics on our webpages? If I cache the results is it more feasible? Or just occasionally update our stats? I absolutely love Google Analytics for our site metrics, but maybe there's a better solution for this particular need?

like image 971
at. Avatar asked Jul 28 '11 10:07

at.


People also ask

What Can Google Analytics track on website?

In addition to tracking the number of visitors, Google Analytics provides key insights into how your website is performing and what you can do to meet your goals. You can track everything from how much traffic your website is getting to where that traffic is coming from and how visitors are behaving.


1 Answers

So the question is if it's possible to use Google Analytics' API for updating the statistics on our webpages?

Yes, it is. But, the authentication process and xml return may slow things up. You can speed it up by limiting the rows/columns returned. Also, authentication for the way you want to display the data (if I understood you correctly) would require you to use the client authentication method. You send the username and password. Security is an issue.

I have done exactly what you described but had to put a loading graphic on the page for the stats.

If I cache the results is it more feasible? Or just occasionally update our stats?

Either one but caching seems like it would work especially since GA data is not real-time data anyway. You could make the api call and store (or process then store) the returned xml for display later.

I haven't done this but I think I might give it a go. Could even run as a scheduled job.

I absolutely love Google Analytics for our site metrics, but maybe there's a better solution for this particular need?

There are some third-party solutions (googling should root them out) but money and feasibility should be considered.

like image 114
jk. Avatar answered Oct 04 '22 21:10

jk.