tomdyson / wagalytics

A Google Analytics dashboard in your Wagtail admin
MIT License
217 stars 42 forks source link

JS console errors #2

Closed chrxr closed 8 years ago

chrxr commented 8 years ago

Hi @tomdyson,

I've got to the point where everything is installed, but I'm afraid I'm getting a whole load of JS console errors. A screenshot of the console is attached. I'm getting these errors both locally and on production.

It's mostly 403s... Something to do with insufficient permissions? Pretty sure I have my service account setup correctly and added to my GA account

screen shot 2016-02-25 at 13 18 46

tomdyson commented 8 years ago

It looks like permission issues on your account. Are you sure you've got the correct site ID? If you view source for that page, do you see a value for 'access_token'?

tomdyson commented 8 years ago

If so, try requesting

https://www.googleapis.com/analytics/v3/data/ga?ids=ga%3A[your-site-id]&start-date=yesterday&end-date=today&metrics=ga%3Apageviews&filters=ga%3ApagePath%3D%3D%2Ffeatures%2F&access_token=[generated-token]

swapping out [your-site-id] and [generated-token].

chrxr commented 8 years ago

Yes, there is a value in access_token.

{"error":{"errors":[{"domain":"usageLimits","reason":"accessNotConfigured","message":"Access Not Configured. The API (Google Analytics API) is not enabled for your project. Please use the Google Developers Console to update your configuration.","extendedHelp":"https://console.developers.google.com"}],"code":403,"message":"Access Not Configured. The API (Google Analytics API) is not enabled for your project. Please use the Google Developers Console to update your configuration."}}

So, the API wasn't enabled for the project/service account created. I've enabled the API and now everything is great!

Once you create the project & service account, you need to go to the interface below to activate the API for the particular project:

https://console.developers.google.com/apis/api/analytics/overview

That's not mentioned in the setup pages you've linked to, so probably worth including in the readme. But anyway, all is well now for me! Thanks!

coredumperror commented 8 years ago

I ran into this same problem. Because I created a new Project as part of the steps to generate a Service Account, that project didn't have the Analytics API enabled (even though I had enabled it in my previous Projects, which is why I was so confused about it being disabled).

I second the suggestion that this advice should be added to the setup instructions.

mwcbrent commented 8 years ago

One note that caught me up on this is to not use the number starting with UA- but rather the "View ID" under property > account > view > settings in Analytics.