Running the Google Analytics import (GA3 / GA4)
Note: This guide assumes you have already authorized Matomo to access your Google Analytics data. Please ensure that you have followed those steps first.
Once you’ve authorized Matomo, you can begin importing data. You can initiate this through the admin page, or on the command line. Running your import on the command line allows you to see more detailed information about it’s progress as it’s going. Depending on how much data you are importing it can take a long time to finish an import.
Google imposes a daily limit on the number of API requests you can make each day (at most 50,000) and each site (at most 10,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 run over several days until the entire data set is imported.
Setup an import using the admin page
- Go to the Google Analytics Import admin page.
-
Select the Import type.
-
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.
Setup an import using the Command Line for Universal Analytics (GA3)
- 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.
ssh
into your Matomo instance- Run the following commands to import your site:
$ cd /path/to/my/matomo
$ php ./console googleanalyticsimporter:import-reports --property=<property-id> --view=<view-id> --dates=<dates>
Forproperty-id
andview-id
substitute the GA property ID and view ID you noted above. Fordates
specify the date range of date you’d like to import, for example,2017-01-01,2022-04-31
.
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 need to keep it.
Setup an import using the Command Line for GA4
- First you’ll need some information. In your Google Analytics dashboard, open the property selector.
- Take note of the Property ID for the property you want to import.
ssh
into your Matomo instance- Run the following commands to import your site:
$ cd /path/to/my/matomo
$ php ./console googleanalyticsimporter:import-ga4-reports --property="properties/<property-id>" --dates=<dates>
Forproperty-id
substitute the GA4 property ID noted above. Fordates
specify the date range of date you’d like to import, for example,2017-01-01,2022-04-31
.
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 need to keep it.
Importer Options
Importing a Mobile App Property
If your GA property is for a mobile app, then you will need to check the Mobile App
checkbox before starting your import:
This will ensure that Matomo imports the correct data. The Screen Views metric in Google Analytics will be imported and used as the Pageviews metric in matomo. The Screens reports will be imported into the Page Titles reports in Matomo.
If you don’t check this box and your property is for a mobile app, the importer will ignore this data.
Importing Unsupported GA Dimensions
Some GA dimensions do not exist in Matomo, such as the demographics dimensions. You may want to hold onto this information when importing, and it is possible to do so by importing the data into a custom dimension.
In the import form, fill out the “Extra Custom Dimension Mappings” field with the GA dimensions you’d like to import:
Use this list to find the proper IDs for Universal Analytics (GA3) dimensions.
Use this list to find the proper IDs for GA4 dimensions.
When importing, one custom dimension slot will be used up in the imported site for each extra mapping. (Note: there will be an error if there are not enough custom dimension slots in your Matomo.)
After your import
After you finish importing data into Matomo it is a good idea to back up your Matomo’s database. If the imported report data were to be purged or somehow deleted, you would have to re-import the data from GA. And if your GA property has been deleted, the data will be gone forever.
If you regularly backup your database (or your host does it for you), then you don’t really need to worry about this.