@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 Member

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 Member

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 Member

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 Member

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 Member

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.

@HLFH commented on October 21st 2020

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 on November 1st 2020 Member

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 on November 1st 2020 Member

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 on November 2nd 2020

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

This Issue was closed on November 1st 2020
Powered by GitHub Issue Mirror