Import Google Search keywords in Matomo
If you are using Matomo On-Premise, first make sure you have the Search Engine Keywords Performance plugin.
-
Follow instructions in How to set up Google Search Console and verify your website.
-
Follow instructions in How to set up Google OAuth Client config to get your OAuth config.
-
Login to Matomo as Super User, click on “Administration (cog icon)” on the top right, and click on “Search Performance” under “System”. If you are using Matomo for WordPress, you first need to go to “WP Admin Dashboard -> Matomo Analytics -> Reporting” before completing these steps.
-
Below Google Search Console, click Setup Configuration.
-
Upload the OAuth credentials.
-
Below Connect Google Account(s), click Start oAuth process.
-
Now you can configure your websites to import Keywords for. Below Configure websites click the Add configuration.
Congratulations! You’re all set and your Google keywords will be imported in the new Matomo (Piwik) Search Keywords report.
How to set up Google Search Console and verify your website
To import your Google Search Keywords in Matomo, you need to sign in to the Google Search Console and check your website is verified. Follow the steps below:
-
Sign in to Google Search Console (you may need to create an account). Google Search Console is a free service offered by Google that helps you monitor and maintain your site’s presence in Google Search results.
-
After signing in, you can add a property from the option located in the top left.
You will then be presented with two options: ‘Domain‘ or ‘URL prefix‘.
(If you have created a new account, you will instead be presented with the below options right away)
–Domain: This option includes all subdomains (e.g., m., www.) and multiple protocols (e.g., http, https, ftp). It covers a broader scope of your website.
–URL Prefix: This option includes only URLs with the specified prefix, including the protocol (e.g., http/https). It focuses on a specific subset of your website’s URLs.
Choose the option that accurately reflects your website by entering either the domain or URL. Once you’ve made your selection, you will receive specific instructions on how to verify your chosen domain. The verification method will vary depending on the option you have chosen.
The verification process may involve adding a DNS record to your domain name or uploading an HTML file to your web hosting. Follow the provided instructions accordingly.
Once your website is verified: congratulations!
You can now proceed to setting up the Google Search Keywords import in Matomo
How to set up 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.
If at any time you need to make changes to the OAuth Configuration, you will need to download the new OAuth Client credentials and upload them to Matomo in order for the changes to work.
Follow these steps to get your OAuth Client Config and use the Matomo Google Search Integration:
-
Sign in to the Google API Console
-
Click Select a project in the menu.
-
To create a new project click the “New Project” button in the overlay:
-
Give your new Project a useful name (for example
Matomo Search Integration
). -
After your project has been created, select it manually in the project list and click “open”.
-
Click on Library in the menu on the left, then search for Google Search Console API, and click on the item Google Search Console API. Then on the description page of this API, click the Enable button.
-
Next we need to setup the OAuth Consent Screen. Click on Menu icon next to the Google logo at the top and navigate to APIs & Services > OAuth Consent Screen in the left menu. Select External and then click Create.
-
Choose a name for your app, then click Add Domain and add the top level domain of your matomo instance e.g. matomo.cloud
-
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. -
Click Save and Continue for both the Scopes and Test Users steps
-
On the Summary step click Back to Dashboard
-
On the dashboard, click Publish App under Publishing Status.
-
Verify that the popup says “You do not need to submit your app for verification” and click Confirm
-
Go to the Credentials tab on the left menu
-
Click Create Credentials
-
Select OAuth Client ID
-
Select Web Application as the Application Type
-
Set a name for the application, for example
Matomo at https://matomo.my-website.example
-
Click on Add URI under Authorized JavaScript origins and set it to your Matomo URL domain for example:
https://matomo.my-website.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. (sohttps://my-website.example
in case ofhttps://my-website.example/matomo/
) -
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=SearchEngineKeywordsPerformance&action=processAuthCode
added at the end. For example:https://matomo.my-website.com/index.php?module=SearchEngineKeywordsPerformance&action=processAuthCode
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,http://mysite.com/wp-content/plugins/matomo/app/index.php?module=SearchEngineKeywordsPerformance&action=processAuthCode
Note: that the URL for Matomo does not have to have a subdomain, that is just an example. -
Once you have entered the two URIs, click Create to finish creating the OAuth Client Credentials
-
You will now be presented with the OAuth credentials that were just created. Click on DOWNLOAD JSON to download the OAuth credentials.
(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 client 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 matomo.cloud (unsafe)” or “Go to yourdomain.com (unsafe)”
Congratulations! You can now proceed to setting up the Google Search Keywords import in Matomo (Go back to the top of this page to see the instructions).