BoB
BoB

Reputation: 81

Read download count from google-analytics using Javascript

I am using the async version of the code in an onclick event for each download. I would like to read the count from Google-Analytics for a labeled event, to show next to the download button.

Is this possible in Javascript? I do not have the option to use php or perl.

Thanks, BoB

Upvotes: 0

Views: 193

Answers (1)

Eduardo
Eduardo

Reputation: 22834

Even if possible you should not do it.

The google analytics data export API requires you to sign in using your google credentials to do API requests. Once you do it you have access to all your data on all your profiles.

So doing it means using client side code to log on the API using your credentials, and get only one metric, although all other are available.

The right way to do it is to use server side code to get that data and store it somewhere to be later queried by Javascript code.

Google Analytics data can be misleading and there's no reason you go though all this to get the download count. You're better just coding your own backend to count downloads.

Upvotes: 1

Related Questions