Moving piwik.js on website

(Giorgio) #1

Hi, I’m new in piwik.
I’m having a problem loading the piwik.js, it is slow.
in your opinion is it possible to copy the piwik.js on the monitored website?

and then modify the tracking code in this way?

adding var u_local

  function embedPiwik() {
	var u_local="/system/modules/resources/js/";
	var u="//piwik.domain/piwik/";
	_paq.push(['setTrackerUrl', u+'piwik.php']);
	_paq.push(['setSiteId', '1']);
	var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
	g.type='text/javascript'; g.async=true; g.defer=true; g.src=u_local+'piwik.js'; s.parentNode.insertBefore(g,s);



(Lukas Winkler) #2


It’s odd that piwik.js is loading slowly as it is just a file served by your webserver. Of course nothing stops you from copying it over to another webserver (but I am not sure why this one would be faster). Keep in mind that piwik.js can change on every Matomo update, plugin install/uninstall/update and possibly even at more events.

In the tracking code you need to set g.src= to the correct URL.