Tweaking the Javascript snippet


#1

I see that the Javascript snippet references my URL 3 times, twice for pkBaseURL and once for the image.

How is pkBaseURL used?

Should I have the image refer to http or https based on whether the page request is http or https in order to avoid browser warnings?


(Matthieu Aubry) #2

Piwik works for http/https by default since it is detected in the JS code


#3

What about the hard-coded “http://” inside the noscript tag?


(Matthieu Aubry) #4

You can remove the noscript tag


#5

What functionality does it provide that is lost by removing it?


#6

Noscript is executed if a browser has no javascript enabled. Currently there is no browser used on the marked without JS but there are blocking addons out there. BUT: Not all of those blocking addons respect the noscript tag. So it`s more or less a “maybe” fallback for old browsers.


#7

Got it, thank you. Would it be wise for me to display the contents of noscript with http or https depending on the protocol of the page request? Otherwise, I think there is the possibility of browser warnings?


#8

How about changing the noscript link to be relative instead of absolute so it’s served via http or https depending on how the page is served?


(Matthieu Aubry) #9

It might also work if you simply remove the http and leave only ://example.org/piwik


#10

Not rly to recommend. Gives time to time strange errors in some browsers.

But if you do not use a SSL Connection it`s fine. Btw. remember: Piwik needs to installed with a SSL Cert too if you going to use it on a ssl webpage.


#11

Not rly to recommend. Gives time to time strange errors in some browsers.

May I ask which method of these is not recommended:

I think the first one should be OK. Relative links are a tried-and-true method.

Piwik needs to installed with a SSL Cert too if you going to use it on a ssl webpage.

My website runs on the same domain name which serves piwik.js and piwik.php. That domain has an SSL certificate installed so I’m OK, right?


#12

Yeah if you have piwik in a subdir the relative methode is the best one. I for myself have one piwik server for a dozends of projects on a other domain. But This domain has a valid SSL Cert so i use a static https:// in the noscript part.


#13

Got it, thanks Solariz and Matt.