Adding Umami Analytics script to a NextCloud instance

Sorry to hear you’re facing problems. :slightly_frowning_face:

The community help forum (help.nextcloud.com) is for home and non-enterprise users. Support is provided by other community members on a best effort / “as available” basis. All of those responding are volunteering their time to help you.

If you’re using Nextcloud in a business/critical setting, paid and SLA-based support services can be accessed via portal.nextcloud.com where Nextcloud engineers can help ensure your business keeps running smoothly.

Getting help

In order to help you as efficiently (and quickly!) as possible, please fill in as much of the below requested information as you can.

Before clicking submit: Please check if your query is already addressed via the following resources:

(Utilizing these existing resources is typically faster. It also helps reduce the load on our generous volunteers while elevating the signal to noise ratio of the forums otherwise arising from the same queries being posted repeatedly).

I’m hoping this tip helps someone - as I wasn’t able to find this: how can you add a reference to a Javascript analytics ‘bug’, which is usually specified in the form of a ‘<script>’, usually something like <script defer src="your.analytics.provider/script.js" data-website-id="nnnnnnn-nnnn-nnnn-nnnn-nnnnnnnnnnnnn"></script> ?

Folks recommended the ‘JSLoader’ App, but it doesn’t accept the ‘<script>’ tag as it is… so how can it be used to achieve the goal? Like this - entered into the JSLoader code field (on yourncsite/settings/admin/jsloader):

let myScript = document.createElement('script'); 
myScript.src = "https://umami.mydomain/script.js";
myScript.setAttribute("data-website-id", "nnnnnnn-nnnn-nnnn-nnnn-nnnnnnnnnnnnn");
myScript.setAttribute("defer", "");
document.body.appendChild(myScript);

Where you replace the URL with the one provided by your Analytics provider, and the website id (in the case of Umami, it’s in the form of nnnnnnn-nnnn-nnnn-nnnn-nnnnnnnnnnnnn) too. And to avoid Content Security Policy issues, make sure you include the URL (including https://) in the supplied field.

Note: when testing, you’ll get better results by making sure you’ve allowed your Analytics provider in your personal script blocker :blush: