Embedding Matomo is easy. It works much like embedding a YouTube video. You just need to copy and paste a line of code into any context where you can use an iframe tag. Many blogs and most websites will let you do this. Let’s take a look at how you can embed Matomo in a WordPress website. WordPress is one of the most popular open source content management systems. The process is very similar whatever piece of software you are using.
Change User Permissions
First, you have to configure permissions. By default, Matomo will not let other people see your data. You can make your data public in one of two ways:
Publish in a public website or app
By default, report data and all information in your Matomo server are protected and nobody can access it. To view and access any analytics data, Matomo always asks you to sign in with a valid user account. To embed the widgets without your users having to logging in to view them, follow the steps in How do I make Matomo report data public and viewable by anyone?
Learn more in Manage Users documentation).
Embed Matomo widgets on a password protected or private page
If you embed your analytics widgets on a password protected or private page, we recommend in this case that you follow these steps:
- create a new user,
- give it view access to the website you wish to embed in your password protected page,
- copy the ‘token_auth’ of this user from the Manage Users page,
- paste this
&token_auth=your_token_auth_hereat the end of the widget URL in the widget embed HTML code.
Embed a Matomo report in a HTML page
The next step is to choose which Matomo reports you want to embed. In Matomo click in the top right menu on Administration, then click on “Widgets”. In this page all widgets are listed with live preview. When you preview any widget you will see the embed code (highlighted here in red) underneath the preview:
When you have chosen a widget to embed and copied its code, just go to the website in which you wish to insert it, and paste the code where you want it. In the below image, the top downloads report is inserted into a page of its own.
Note: HTML view is selected because an iframe HTML tag is being pasted in:
When you click save, you will see the familiar Matomo interface embedded in your site:
Embed the Matomo dashboard in a HTML page
As well as embedding single reports, you can also embed the full Matomo Dashboard. In Matomo, click on Administration in the top right corner, then “Platform > Widgets”. In this page you will find the link to embed the full dashboard. This can be very useful for users who wish to integrate Matomo inside another dashboard or app.
Embed the full Matomo app anywhere
You may also embed the full Matomo application within an Iframe. To make this work, a small change to the config file is required: see this FAQ.
Once you have configured the INI setting to allow iframes, you can embed the full Matomo App directly in any HTML page in an iframe.
Embed a static image graph of your analytics data
It is also possible to include a PNG image (line graph, vertical bar graph or pie chart) that plots the data for any Matomo report. For more information, check out the documentation about Embedding Static Graph Images.
Customising the widgets
To customise the widget date, website id or initial view (table, graph chart, table showing goal metrics) you can edit the parameters in the URL in the embed code:
- idSite – website ID
- period – day, week, month, or year
- date – a date (YYYY-MM-DD), date range (YYYY-MM-DD,YYYY-MM-DD), or alias (e.g., ‘today’)
- disableLink – typically set to 1; when enabled, clicking on the evolution graph redirects the page to the Matomo dashboard
- viewDataTable – defines the widget ‘view’, and can have the following values:
For example, to show widget data as a Bar Chart by default, you can set in the widget URL
Using the Reporting HTTP APIs to request any report data or raw data
All the raw user data in Matomo, as well as all your report data, can be exported with our powerful Reporting APIs.
Making Matomo reports data publicly available
By default all your analytics data is protected by Matomo, and users must sign in with a valid account that has permission to view the data. In some cases (although rarely), you may want to make your analytics data publicly accessible. Learn more in this FAQ: How do I make Matomo report data public and viewable by anyone?.