Before we can start exporting Google Analytics data from their API and importing it into your Matomo, there are two setup steps to go through: 1) Creating Google OAuth Client Config and 2) Authorizing Matomo to export your Google Analytics data. These two steps need to be done only once.

1) Optional: Purchase a temporary Google Workspace account

This step is not required, but makes the process of importing easier.

There are two types of Google projects that can be defined in the Google API Console: external and internal.

External apps can be created by anyone, but Google places a limit on the amount of time API authorizations can be used: after a week they will expire. Using this type of app, you will have to manually re-authorize Matomo every week in order for your imports to continue running. It’s unfortunate, but Google creates this policy and we don’t have a way around it.

Internal apps, on the other hand, do not have this limitation. Using an internal app you will only have to authorize Matomo once, BUT, internal apps are only available to users that have purchased Google Workspace. If you’d like to avoid the inconvenience of having to regularly re-authorize Matomo, it is advised to purchase an account for however long you need to run imports from Google Analytics.

2) Creating Google OAuth Client Config

Important note before we start: At no point during these steps will you be required to submit your ‘app’ to Google for verification. If you are prompted to submit your ‘app’ and do not have the option to click no or cancel, then please review the steps in this guide again to ensure that you have not missed an important step, or added additional information where not necessary.

Follow these steps to get your OAuth Client Config:

  1. Sign in to the Google API Console

  2. Click Select a project in the menu.

  3. To create a new project click the “New Project” button in the overlay:

  4. Give your new Project a useful name (for example Matomo Google Analytics Importer).

  5. After your project has been created, select it manually in the project list and click “open”.

  6. Click on Library in the menu on the left, then search for Google Analytics API, and click on the item Google Analytics API. Then on the description page of this API, click the Enable button.

  7. Do the same for the Google Analytics Reporting API.

  8. Next we need to setup the OAuth Consent Screen. Click on the Google logo at the top to get back to the dashboard, afterwards click on OAuth Consent Screen in the left menu. If you have a Google Workspace account, select Internal. Otherwise, select External. Then click Create.

  9. Choose a name for your app, then click Add Domain and add the top level domain of your matomo instance e.g.

  10. Select your email address from the drop down menu under User support email, and fill in your email address for Developer contact information
    Important note: Do not upload an App logo here, doing so will require you to submit your ‘app’ to Google for verification which can take several months to complete.

  11. Click Save and Continue and then click Add or Remove Scopes

  12. Select the “Google Analytics API” scope with the readonly property and click Update then click Save and Continue

  13. Next, we need to add Test Users in order to allow access to the Google Analytics API Scope.
    Click Add Users and enter the email address you will be using to access the Google Analytics Data.

  14. Click Save and Continue and then click Back to Dashboard

  15. Go to the Credentials tab on the left menu

  16. Click Create Credentials

  17. Select OAuth Client ID

  18. Select Web Application as the Application Type

  19. Set a name for the application, for example Matomo at

  20. Click on Add URI under Authorized JavaScript origins and set it to your Matomo URL domain for example:
    Note: This needs to be a domain. If you have installed Matomo into a subdirectory, you need to enter the domain without the path. (so https://my-website.example in case of https://my-website.example/matomo/)

  21. Click on Add URI under Authorized redirect URIs. This needs to be set to your Matomo URL with this special URL/query /index.php?module=GoogleAnalyticsImporter&action=processAuthCode added at the end. For example:
    Note: the URLs above are HTTPS: we highly recommend you run your Matomo instance over SSL. If your Matomo doesn’t support https yet, you can replace the URL and use http.
    If you are using Matomo for WordPress: the URL must begin with the entire path to Matomo’s admin page, eg,
    Note: that the URL for Matomo does not have to have a subdomain, that is just an example.

  22. Once you have entered the two URIs, click Create to finish creating the OAuth Client Credentials

  23. You will now be presented with the OAuth credentials that were just created, you can click Ok to close this dialog, and then download your OAuth client credentials by clicking the download icon on the credentials overview page. (Note: if you change any settings above at a later point for example to fix a typo in one of the values, you will need to download the OAuth credentials again and re-upload it in Matomo.)

The steps in creating your OAuth Client Configuration are now complete. The ‘app’ that has been created during this process can remain as a ‘Testing’ or ‘Test Phase’ app without any need to submit it for review.
At no point during these steps would you have been required to submit your ‘app’ to Google for verification. If were prompted to submit your ‘app’ and did not have the option to click no or cancel, then please review the steps in this guide again to ensure that you have not missed an important step, or added additional information where not necessary.

You may still receive a warning from Google when completing the OAuth process saying “Google hasn’t verified this app”.
In this case, you can safely continue by clicking on “Advanced”, and then “Go to (unsafe)” or “Go to (unsafe)”

3) Authorizing Matomo

Once you have downloaded your OAuth client credentials, you can authorize your Matomo to have access to your Google Analytics data:

  1. Login as a Super User in Matomo and go to Administration.

  2. In the left menu, click on System and then Google Analytics Import. If you are not seeing this menu, make sure you have installed the GoogleAnalyticsImporter plugin.

  3. Upload the OAuth client credentials you downloaded in How to set up Google OAuth Client config by clicking Configuration File, selecting the file, and clicking Save.
    Upload Client Config for Importer

  4. Now, click Authorize and follow the prompts to give Matomo access to your Google Analytics data.
    Authorize the Importer

Important note: If you selected External when configuring your Google project, you may have to regularly re-authorize Matomo. Google makes sure authorizations for test users in External projects expire in seven days, at which point your imports will fail and you will have to re-authorize Matomo. Unfortunately, the only way around this is to temporarily purchase a Google Workspace account and make your project Internal.