Dashboard API and hiding segment editor

(Louis) #1

Anybody know how to launch zen mode and/or hide segment editor when pulling an entire dashboard through an iframe using the API.

Or perhaps what style changes to amend to implement to achieve this.

I am passing custom segments on the fly using url and custom dimensions, so don’t want to show the segment editor in this specific design.

(Roddy A. Stegemann) #2

Have you explored the Dashboard API? In particular,

Dashboard.getDashboards (login = '', returnDefaultIfEmpty = '1')

It returns the following JSON (a Matomo sample):


The presence of the getDashboards() method suggests the presence of a setDashboard() method.

And yes, I agree the Matomo manual has more the feel of an advertising gimmick for the purchase of paid consultation than a rigorous open source manual for further development by freelancers who would like to promote Matomo through their own work and initiative.


(Lukas Winkler) #3


What do you think is wrong with the developer documentation? If you have any specific ideas how to improve them, I can try to allocate some of my free time this summer to try to improve it.

You an also report issues directly on the website repostitory:

As explained here the API you are looking for is Dashboard.createNewDashboardForUser.

If you want to display just the dashboard without an UI (similar to zen mode) you can try this API as explained on the widget page.


(Louis) #4

Thanks for taking time to reply, but what you have suggested is what I am already using. If you widgetize the full dashboard via the API then the segment editor is also shown as part of that widget and I don’t want to show this element.

I like the documentation, use the Matomo help pages every week.

(Roddy A. Stegemann) #5

Hi, Lukas! It is hard to know where to begin. This entry is, however, a good case in point. The manual provides a sample outcome for a method name that shows clearly what modules the current Dashboard contains and then provides a method name for customizing it. Unfortunately, the only example provided for customization is how to restore the default setting. Or, am I completely in error, and that the parameter value

addDefaultWidgets = '1'

in the phrase

Dashboard.createNewDashboardForUser (login, dashboardName = '', addDefaultWidgets = '1')

means the number of new “default” widgets that I would like to add? But, things become worse, for once set how would I go about deleting a widget (Louis’ question ultimately)? Then, under the assumption that the word “default” refers to widgets that are a part of the CORE, I am left with the question, “May I add widgets that are not part of the core?”

Now, please Lukas, do not attempt to clear up my doubts with regard to this question for my sake, for I am currently adrift with other Matomo matters that are more pressing, but no less confusing. Louis’ entry caught my eye for future development, and I sought to lend a hand in good faith. I like to return what I take, and others such as yourself have helped me. I am not trying to be overcritical, only real for the sake of everyone who like me is a struggling start-up.


(Louis) #6

I know how to show/hide widgets, just the segment editor I want to control and really without having to customise the style templates as I don’t have access to that area of our server.

A great addition to Matomo would be finer governance of the user policy as I find that anonymous, or read is just too binary for what I need. Admin and super user are too high above read access to assist with most of my requirements and so I end up building a lot of custom tools, either web based or in excel with power query.

Either way, I do love Matomo :clap:t2: thank you.

(Roddy A. Stegemann) #7

Louis, unless I am mistaken, your authorization token gives you complete access to the Matomo reporting API. You have only to send your authorization token with an HTTP Request. In lieu of the fact that there does not appear to be an ON/OFF button for segment editing, you would simply drop the &segment parameter when making a request.



SOURCE: Segmentation: API Reference - Matomo Analytics (formerly Piwik Analytics) - Developer Docs - v3

In effect, you would have to build your own Dashboard. This you could clearly do without having to apply the mysterious

Dashboard.createNewDashboardForUser( )

method that may or may not allow you to specify the &segment parameter.

Also, if you should discover through experimentation how to make this method work, you might want to try adding the segment content operator followed by null or nothing in an effort to suppress the editor – namely,



P.S. Do not forget to register your suggestion with Matomo, by the way. It is obviously a good idea.

(Louis) #8

I probably didn’t explain myself properly here. I am not creating a dashboard in this specific API call, that has already successful completed in a previous task. This use case is to widgetise the full dashboard for a specific user, once their dashboard is built and just hide the segment editor only.

Wether a segment is passed or not doesn’t effect the returned dashboard view only the returned analytics within the widgets for that dashboard ID or default if no dashboard ID is declared. The segment editor would just load with “All Visits” and not a custom or previously added segment for that user.


Widgetising the full dashboard will by default always show the segment editor, along with the widgets (default or customised) for the user that the token_auth belongs to. What this means is that the user can add segments themselves and I don’t want that to happen for this use case.

I don’t have a web host for this and that is why I am using a JavaScript bookmarklet to call the dashboard in an iframe and use jquery to overlay that iframe over the webpage/area they want to segment by (applied by code not by the user).

I don’t expect Matomo to do the above, just only if there was a url parameter I was missing that could hide the actual segment editor.

This feels like a feature request, I appreciate you taking the time and effort to collaborate on this @Kiusau.

(Roddy A. Stegemann) #9

OK. So open the resulting document in Page Source, discover the HTML element that contains the segment option, and hide or simply eliminate it with a script.

I definitely agree that the option that you seek should be included, and I would very much like someday to be able to display widgets without having to expose one’s authorization code. Unfortunately, the Matomo to-do list is quite long, and I do not expect anything to happen in short order, if ever.

I do believe that much can be achieved with something called w_get, but for the moment I do not have access to my own terminal commands that would allow be to install and activate it…


(Louis) #10

Thanks @Kiusau for the suggestion.

I don’t think that’ll work due to Matomo being hosted on a different domain to the site being tracked (same origin policy) but I will definitely test this.

(Roddy A. Stegemann) #11

But, why? Once the data has been downloaded it is yours to do with as you like.
Please let us know the outcome of your experiment.


(Louis) #12

In this case I am not downloading a data file type, like json or csv.

Widgetising the full dashboard doesn’t work in that way.

To my knowledge web browsers don’t allow (by design) iframe content to be changed on a different domain to its source.

Also, I only wanted to know if there was a parameter that could be utilised, not inflate my bookmarklet by adding in lots of extra code as I can’t reference any assets due to having no web host and so all of the functionality is produced on the fly.

Thanks for all your suggestions, I think we have reached a conclusion. That there isn’t a parameter to control the segment editor visual element in this widget.

(Matthieu Aubry) #13

Hi @Louis_Pitchforth
Thanks for the suggestion. I suggest you create a feature request in our tracker so can keep track of it: Issues · matomo-org/matomo · GitHub


(Louis) #14

Thanks for the suggestion @matthieu, I have raised that now:

Control visibility of segment editor when widgetising full dashboard · Issue #13129 · matomo-org/matomo · GitHub

(Roddy A. Stegemann) #15

I believe that you are correct on this point:

To my knowledge web browsers don’t allow (by design) iframe content to be changed on a different domain to its source.

If you have access to it, use w_get. With this you should be able to call the contents of the dashboard without the iframe into a separate document, alter it there, and then feed the modified dashboard into your own iframe via the src attribute.

Now, I have not yet tried this myself, but it is surely my intention in the near future as a means to hide my authorization token. Simply, for the moment I do not have access to w_get