This post is geared towards completing the installation for the Google Analytics Post Pageviews plugin for WordPress. It is not straightforward and the provided instructions are either dated or lacking. Either way this consumed a lot of time to figure out due to the vague nature of documentation available everywhere.
No matter what you do, you keep getting the following error (or something like it if you are troubleshooting a similar issue):
The redirect URI in the request, http://yourWordPressWebSite.com/wp-admin/options-general.php?page=google-analytics-post-pageviews, does not match the ones authorized for the OAuth client. Visit https://console.developers.google.com/apis/credentials/oauthclient/825054562834407666210?project=404754253856 to update the authorized redirect URIs.
Pretty frustrating and bewildering error, especially if you have never done this before.
In order to troubleshoot this problem accurately you must have the following items setup already (instructions as of 06/05/2017):
- Google analytics account: https://www.google.com/analytics/
- Google API – A google api project to use in conjunction with the “Google Analytics Post Pageviews” plugin: https://console.developers.google.com/apis/
- Analytics API – Enable the Analytics API for this project. You have to click on “Library” side menu item in order to access the available APIs (left side).
Follow all of the instructions shown until it is enabled.
- Next you want to click on the “Credentials” side menu item in order to continue to the confusing part.
- Complete the instructions on the “OAuth consent screen”, which is very straight forward – just make sure to fill everything out the best you can.
- Complete the “Domain verification”, which is slightly tedious but easy to complete, just follow the steps.
- Go to the next section for setting up the Credentials which is the confusing part.
The confusing part
- Click on “Create credentials” to make a drop down menu appear
- Select “OAuth client ID”
- Select the “Web application” radio button
- Enter a name, you can name this whatever the heck you want
- Authorized redirect URIs – TADAHHHH!!! It’s that thing you couldn’t find and it’s the thing that the error above was saying you screwed up. Congrats, enter your proper URL. In the context of the “Google Analytics Post Pageviews” plugin – that URL is provided to you via the plugin and looks like this: http://yourWordPressWebSite.com/wp-admin/options-general.php?page=google-analytics-post-pageviews (FYI: You are allowed to enter multiple URLs)
- Hit the create button
After pressing the create button you are presented with the above dialogue. Go ahead and copy that data respectively into the “Google Analytics Post Pageviews” plugin’s text fields. You can then test these values and you should be taken to the Google API dashboard. The following is example data:
- Client Id: 576073251342-q9ueqg1d8igqbn5m5s53m2ihmk7mefds.apps.googleusercontent.com
- Client secret: uhRBFdKcBN1BuEFho4ZoprUK
That’s all there is to it.
The following links are all related to the above, the answers provided hinted at what to do, but didn’t drive anything home in my opinion. Still good to review if this post didn’t help you.