Self-hosted Matomo on static site

I am considering trying out Matomo on my site.
However, my site is completely static. There is no way to execute PHP scripts, etc. on this server.

Can I set up Matomo on a different server that supports PHP, etc. and runs Matomo and then still use Matomo on my static site by just inserting the javascript snippit into my static website’s pages?

of course. That’s the normal setup i’d say. In your case the client browser is downloading all your (static) content incl. the javascript tracking code. The javascript code is run by the client browser and calls code running on the matomo server. that’s all.

1 Like

As the name it say: javascript tracking code. There is no PHP tracking “code” for the HTML document. Only additional a image tracking for the HTML document. PHP tracking works with the server logs, and is a own solution, and by this the HTML document is untouched.

Thank you for a clear and concise response. This is what I was looking to find out.

Thanks for clarifying that there is no PHP code.
I tried setting this up on a site. It seems the tracking code is javascript - not an image.
I do see mentions in the API documentation of using an image optionally. Would you recommend using an image instead of javascript?

That is each matomo user owns decision.

Yes, I understand that. What I am not sure of, however, is what are the main advantages/disadvantages of one over the other. Since you seem to be using an image, I suppose you already assessed the pros and cons for each method.
You appear to be knowledgeable on this topic so I would love to hear your thoughts!

some users deactivate javascript and wouldnt be tracked. using the image as a fallback can prevent this.
use <noscript></noscript>.

Tracking HTTP API: API Reference - Matomo Analytics (formerly Piwik Analytics) - Developer Docs - v5

1 Like