Use Google Analytics to display data on our web page?

On some of our pages we show some statistics, for example, how many times this page was viewed today, the number of times it was viewed last week, etc. In addition, we have a common statistics page on which we list the pages in the order that were considered most.

Today, we simply insert these pageviews and the number of events into our database as they occur. We also send them to Google Analytics using regular page tracking and their APIs. Ideally, instead of querying our database to display statistics on our web pages, we simply request the Google Analytics API. Google Analytics makes FAR more effective by finding out who is truly unique and avoiding counting people who artificially increase the number of page views (we allow people to create pages on our site).

So the question is, can the Google Analytics API be used to update statistics on our web pages? If I cache the results, is this more possible? Or just update our statistics occasionally? I absolutely love Google Analytics for our site metrics, but maybe there is a better solution for this particular need?

+6
source share
1 answer

So the question is, can the Google Analytics API be used to update statistics on our web pages?

Yes it is. But the authentication process and xml return can slow down. You can speed it up by restricting the returned rows / columns. In addition, authentication for how you want to display data (if I understand you correctly) will require the use of a client authentication method. You are sending username and password. Security is a problem.

I did exactly what you described, but had to put the loading schedule on the statistics page.

If I cache the results, is this more possible? Or just update our statistics occasionally?

Either one, but caching seems to work, especially because GA data is not real-time data. You can make an api call and save (or process, then save) the returned xml for display later.

I did not do this, but I think I could leave. It can even run as a scheduled task.

I really like Google Analytics for our site metrics, but maybe there is a better solution for this particular need?

There are some third-party solutions (googling should eradicate them), but you need to consider money and feasibility.

+5
source

Source: https://habr.com/ru/post/893763/


All Articles