The GoogleAnalyticsImporter plugin imports reports from Google Analytics into a Matomo instance.
When you run an import, your Google Analytics (GA) Property will be automatically created as a Website into Matomo (as well as your Goals and Custom dimensions) and all historical reports in GA will be imported so you can view all your web analytics data in Matomo.
The latest Matomo 3.12.0 beta version is required to use the Google Analytics importer: learn more how to upgrade to latest beta release.
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) Creating Google OAuth Client Config
Follow these steps to get your OAuth Client Config:
Sign in to the Google API Console
Now you will create the OAuth Client Credentials. Click on the Google logo at the top, to get back to the dashboard, afterwards click on Credentials in the left menu. Then click Create credentials and choose the OAuth client ID option:
You will now be advised to create a product name for the OAuth consent screen. Click on the link Create consent screen and enter a product name (for example
Matomo Import). As authorized domain you need to add the top level domain of your Matomo instance (for example matomo.cloud for a cloud hosted Matomo) .You can leave the other fields blank. Click Save.
Now you will create the credentials. You should be able to click under Application type a radio button called
Web application. (If you cannot see this, click again on Create Credentials and choose the OAuth client ID option). Now you need to fill in the following fields:
- Name: we recommend to set it to your Matomo URL 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.examplein case of
- Authorized redirect URIs: needs to be set to your Matomo URL with this special URL/query
/index.php?module=GoogleAnalyticsImporter&action=processAuthCodeadded 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.
- Name: we recommend to set it to your Matomo URL for example:
2) Authorizing Matomo
Once you have downloaded your OAuth client credentials, you can authorize your Matomo to have access to your Google Analytics data:
Login as a Super User in Matomo and go to Administration.
Click on Google Analytics Import on the left menu.
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.
Running the Google Analytics import
Once you’ve authorized Matomo, you can begin importing data. This is primarily done through the admin page, though you can use the command line as well. Depending on how much data you are importing it can take a long time to finish (more than one day in most cases).
Note: Google imposes a daily limit on the number of API requests you can make each day (at most 50,000). The import will hit this limit after importing about 4 months of data where every day has data. This takes just a couple of hours. This means the import has to be run over several days until the entire data set is imported.
Using the admin page
To use the admin UI:
- Go to the Google Analytics Import admin page.
Fill out the Schedule an Import form and click Start:
As the import continues, you will be able to monitor progress through the Import Jobs table below:
Refresh the page to get an updated status at any time.
Once the import is marked as finished, feel free to delete the status. If an import fails, you can view the logs located in
/path/to/your/matomo/tmp/logs/. There should be one for each job.
Using the Command Line
You can also run the import on the command line if you’d like to see more information about it’s progress as it’s going:
- First you’ll need some information. In your Google Analytics dashboard, open the property selector.
- Take note of the Property ID and the View ID for the property/view you want to import.
sshinto your Matomo instance
- Run the following commands to import your site:
$ cd /path/to/my/matomo
$ ./console googleanalyticsimporter:import-reports --property=<property-id> --view=<view-id> --dates=<dates>
view-idsubstitute the GA property ID and view ID you noted above. For
datesspecify the date range of date you’d like to import, for example,
Then just wait until the import finishes, which could take some time.
If you would like to resume an existing import, supply the
--idsite=<idSite> parameter with the site that was created for this import (this will be in the import status table in the admin page).
Once the import finishes, you can remove the authorization you granted earlier. Matomo only needs access to Google Analytics while importing data, afterwards there’s no point in keeping it there.
Not all data in Google Analytics is accessible through the API, however, so some of your data will not show up in Matomo:
- The importer only imports aggregated report data, not the raw visit and action data. This means the Visitor Log,
Ecommerce Log and Segmentation features will not work for imported reports.
- Some reports in Matomo are not supported in Google Analytics, such as the “Search Keywords with No Results” and Contents reports. These reports will not show data after import.
- Some reports from Google Analytics are not yet imported into Matomo (such as Funnels reports). If you find any missing report in Matomo you expected to see imported, please let us know the details in the issue tracker.
- Google strips the search parameter from internal site search URLs, but shows those URLs in the page URLs reports. This means when we import that report, we can’t tell if one of those pages was actually an internal site search, so in imported reports, site search page URLs will be included in the Page URLs and Page Titles reports.
- Google’s ecommerce conversion rate is different from Matomo’s. Google defines this as the number of transactions per session, where Matomo defines it as the percent of visits that have at least one order. So this metric cannot be imported.
- Exit and entrance rates in Google are different than in Matomo. Matomo defines the entrance/exit rate as the percent of times a page URL/page title was the first/last pageview in a visit. In Google Analytics, the rates are defined as the percent of all hits for which a page URL/title is the first/last pageview in a session. So the rates will look different in Matomo.
- Additionally, Google Analytics doesn’t always set the session count when logging pageviews (see their docs for more info). This means some sessions won’t be counted by Google Analytics, and the session count could be lower than it should be for some actions. In this case, the exit/entrance rate will be calculated as > 100%. This doesn’t affect Google Analytics, because the entrance/exit rate there is calculated using the total number of hits and not the number of sessions.
- Product reports are missing the product conversion rate and visits metric, since sessions cannot be queried with product dimensions through the Google Analytics API.
- The importer assumes you have setup GeoIp2. If you don’t, the data will be imported properly, but the reports will display many Unknown regions, until you install GeoIp2.