Errors on Google import using Admin page

I tied importing Google analytics via the Admin page but I’m receiving a long error:

Error on day 2017-05-15, { “error”: { “code”: 401, “message”: "Request had invalid authentication credentials. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.", “errors”: [ { “message”: “Invalid Credentials”, “domain”: “global”, “reason”: “authError”, “location”: “Authorization”, “locationType”: “header” } ], “status”: “UNAUTHENTICATED” } }

I have no idea how to debug this. Any help?

2 previous (unresolved) posts about this problem… I suggest continue on the older one:

I’m returning to my post because I could not find help in the others.
First let me point out that your video tutorial is so outdated compared to the current GA dashboard. So I’m using the text tutorial.

I’m at point 21 of the tutorial (Click on Add URI under Authorized redirect URIs where it says that a special URL/query/ should be appended to the domain), but on authorizing the importer I get a “could not verify token” error, so I have a doubt:
my Matomo runs on-premise under https://analytics.mysite.com but I also use Wordpress and the tutorial suggests to use https://mysite.com/wp-content/plugins/matomo/app/
yet my plugin has a different name https://mywebsite.com/wp-content/plugins/wp-piwik/ and no /app folder

So, should use https://analytics.mywebsite.com/index.php?module=....
or https://mywebsite.com/plugins/wp-piwik/index.php?module=....
or what?

I need some help from the Matomo staff. Thank you.

@innocraft, I am a little bit lost here… :wink:

I’m lost too, but I think it’s the tutorials that are lacking information. Let’s recap:
I have on-premise but on creating the OAuth I don’t know what should I write in the Authorized redirect URIs field because I cannot determine if I must include my on-premise url or the Wordpress one. The confusion is also created because I don’t have /wp-content/plugins/matomo/app/ but /wp-content/plugins/wp-piwik/

@mariajones no I haven’t and I’m quite disappointed that Matomo devs don’t give a proper tutorial on such an important topic

it’s actually getting worse, I got the following messages:
Matomo cannot find PHP shell_exec, exec, nohup.
I have those disabled/deleted because I followed other suggestions. So it’s really not clear how to setup Google Importer.

Plus, this other error:
The last archive was successfully executed 3 days ago. Check to have configured a crontab to call core:archive and have configured MAILTO. You can try with command: /.../console --matomo-domain=/..../ core:archive
But the tutorial for that says that it’s not needed with Wordpress.

No clue really.

Hi @Criss ,

Indeed the tutorial is little out of date, as Google changed things drastically in this space.

Information about WordPress provided is only applicable for the users who use Matomo for WordPress. It is a plugin which gives you fully functional Matomo and it is available as a WordPress plugin and it is completely different from Matomo On-Premise.

As I read your message it seems like you’re using Matomo On-Premise, in this case you should use https://analytics.mysite.com/index.php?module=GoogleAnalyticsImporter&action=processAuthCode

dear @karthik, you must clarify one thing for me as I’m using both Wordpress and On-premise: is the WP plugin unnecessary? Is it only to show statistics in WP backend or is it that On-premise wont work without it?
Plus, the tutorial link you are giving me is broken.

is the WP plugin necessary?

Hi @Criss, On-Premise will work without the WP Plugin. That plugin is only if you choose to use Matomo for WordPress. For more insight please review What are the differences between Matomo On-Premise and Matomo for WordPress?

sorry for the late reply. It’s still not clear whether On-premise will work if the Wordpress plugin is disabled. Wouldn’t the tracking code stop working? And how will On-premise fetch statistics if the tracking code is missing?

I think the answer is there:

Sorry, I don’t want to sound silly but I still don’t get it.
I have disabled my Piwik a couple of days ago and noticed that analytics are not registered, so this means that it must be enabled within Wordpress in order to let On-premise work. On the other hand, if I use On-Premise, then why does it need to fetch data from within Wordpress environment? I mean, isn’t it independent of whichever technology one uses for his website?

In my understanding, you have to change your Matomo for WordPress (tracking + all Matomo stuffs to gather hits and generate reports) plugin to WP-Matomo plugin (tracking only, you’ll have to set the Matomo target)

…but there’s a clear statement on the matomo for worpress plugin:
Already Matomo On-Premise or Matomo Cloud user? You need to use the WP-Matomo plugin instead of this plugin.,
which is the one I’m using

Then it seems there is some problem in your configuration…
Did you set well the Matomo server URL?
Did you set well the site ID?
Is your Matomo accessible from the Internet? Just test:
https://your-matomo-server/matomo.php?action_name=TEST&idsite=1&rec=1&url=https%3A%2F%2Fyour-site.sample%2Ftest&send_image=0
and check you have a page view (TEST / https://your-site.sample/test)

I believe my On-premise is set well, it has been for long time (statistics are running). Yet, the page you suggest doesn’t return anything, so I cannot test.

The page I “suggested” is just a pattern to test if the tracking is working well, server side…

Then how did you configure the WP-Matomo plugin?

Let me just recap. I don’'t think there’s anything wrong with my tracking code On-premise and Wordpress installation because the statistics are generated. I just want to understand if I can remove Piwik from Wordpress, in order to reduce my plugin list (though, when I disabled it, the statistics have stopped working). I have followed all the tutorials so I believe my On-premise is set up correctly, under a subdomain on my server. Piwik is just installed and running, as there are no manual settings to do.
Besides, I don’t want to go too much away from the original topic, which was that of importing Google Analytics into Matomo.