@fmp777 opened this Issue on February 12th 2016

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 on February 13th 2016 Owner

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 on February 13th 2016 Owner

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 on March 15th 2016 Owner

maybe we should

  • completely remove the <noscript> tag since it is not allowed in the <HEAD>. If we do, maybe we could
  • introduce a new JS Tracking Code option (checkbox) to let users add the <noscript> on demand. When this checkbox is checked, it would also directly add the &rec=1 parameter, saving user the extra step (currently this is documented in FAQ which may be hard to discover for users)

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

@mattab commented on March 15th 2016 Owner

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

part of Piwik's JavaScript tracking code )
@mattab commented on March 15th 2016 Owner

Renamed issue to increase scope.

@braiam commented on January 28th 2017

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;.

@sampablokuper commented on May 31st 2017

@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](https://stackoverflow.com/questions/23824576/noscriptimg-in-head-valid/23824708#23824708).

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.

Powered by GitHub Issue Mirror