matomo-org / matomo

Empowering People Ethically with the leading open source alternative to Google Analytics that gives you full control over your data. Matomo lets you easily collect data from websites & apps and visualise this data and extract insights. Privacy is built-in. Liberating Web Analytics. Star us on Github? +1. And we love Pull Requests!
https://matomo.org/
GNU General Public License v3.0
19.89k stars 2.65k forks source link

Remove <noscript> from default JS tracking code, new checkbox to add <noscript> + remove<p> tag in <noscript> #9770

Closed fmp777 closed 4 years ago

fmp777 commented 8 years ago

Having img without p works just as fine. the P tag could cause unwanted space in the web page that executes the noscript block.

tsteur commented 8 years ago

Good point. However, I presume it is there for valid HTML structure. Eg body element is allowed to have p element but not img.

If the p element causes any troubles re spacing and you do not need valid HTML I recommend to remove it manually.

Are there any opinions if without p should be maybe default and having an option for "valid HTML"?

tsteur commented 8 years ago

Actually, since https://github.com/piwik/piwik/issues/9341 we recommend to put the tracking code into <head> where <noscript> is not allowed anyway. So we could as well remove the <p> maybe.

mattab commented 8 years ago

maybe we should

https://piwik.org/faq/how-to/faq_176/

mattab commented 8 years ago

See also #9776 When tracking code is put in , add a note that fallback noscript should be put in body

(Note that this <noscript> not working by default caused some confusion before: #9360 Lack of parameter in

mattab commented 8 years ago

Renamed issue to increase scope.

braiam commented 7 years ago

the P tag could cause unwanted space in the web page that executes the noscript block.

A way to solve that particular issue is to set the style of the p tag as display: none;.

ghost commented 7 years ago

@tsteur wrote:

Actually, since #9341 we recommend to put the tracking code into <head> where <noscript> is not allowed anyway.

@mattab wrote:

maybe we should completely remove the <noscript> tag since it is not allowed in the <HEAD>

You are both wrong ;) As @braiam points out, <noscript> is allowed in <head>.

However, an <img> in a <noscript> in <head> is not valid.

So, what to do?

My proposed solution

If you want you want the (X)HTML to be valid (yes, please!) and you want to use an <img> element for analytics purposes, you'll need to put that <img> in the <body>.

If you do that, then you might as well follow the advice of @hpvd here and @MattISG here, and put the entire code block just before the </body> tag.

HLFH commented 4 years ago

Any updates on this bad start tag in p in noscript in head issue?

Screenshot 2020-10-21 at 10 05 57

Thanks

mattab commented 4 years ago

fyi @HLFH the noscript is removed from Matomo now by default so you can remove it from your tracking code as well. it should fix the issue.

mattab commented 4 years ago

There is also an option to "Track users with JavaScript disabled" so this was already implemented in full :+1: Screenshot from 2020-11-02 10-32-46

HLFH commented 4 years ago

@mattab Hi Mattab, this issue was the <noscript> tag within <head> was not valid HTML. I finally put the whole Matomo JS code and <noscript> tag before the </body> tag.

But finally or sadly, and regardless of this small issue, I had trouble to have any working tracking with the last version 4.0.0-b4. So I migrated to GA 4.