Closed fmp777 closed 4 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"?
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.
maybe we should
<noscript>
tag since it is not allowed in the <HEAD>
. If we do, maybe we could <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)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
Renamed issue to increase scope.
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;
.
@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?
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.
Any updates on this bad start tag in p in noscript in head issue?
Thanks
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.
There is also an option to "Track users with JavaScript disabled" so this was already implemented in full :+1:
@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.
Having img without p works just as fine. the P tag could cause unwanted space in the web page that executes the noscript block.