Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
fmp777 opened this issue Feb 12, 2016 · 11 comments
Labels
Bug For errors / faults / flaws / inconsistencies etc. worksforme The issue cannot be reproduced and things work as intended.

Comments

@fmp777
Copy link

fmp777 commented Feb 12, 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
Copy link
Member

tsteur commented Feb 13, 2016

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
Copy link
Member

tsteur commented Feb 13, 2016

Actually, since #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 mattab added the Bug For errors / faults / flaws / inconsistencies etc. label Mar 15, 2016
@mattab
Copy link
Member

mattab commented Mar 15, 2016

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
Copy link
Member

mattab commented Mar 15, 2016

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 mattab changed the title noscript should not wrap <img> in <p> Remove <noscript> from default JS tracking code, new checkbox to add <noscript> + remove<p> tag in <noscript> Mar 15, 2016
@mattab
Copy link
Member

mattab commented Mar 15, 2016

Renamed issue to increase scope.

@mattab mattab added this to the 3.0.0 milestone Mar 31, 2016
@braiam
Copy link

braiam commented Jan 28, 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;.

@ghost
Copy link

ghost commented May 31, 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.

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
Copy link

HLFH commented Oct 21, 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
Copy link
Member

mattab commented Nov 1, 2020

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 mattab closed this as completed Nov 1, 2020
@mattab
Copy link
Member

mattab commented Nov 1, 2020

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

@mattab mattab added the worksforme The issue cannot be reproduced and things work as intended. label Nov 1, 2020
@HLFH
Copy link

HLFH commented Nov 2, 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug For errors / faults / flaws / inconsistencies etc. worksforme The issue cannot be reproduced and things work as intended.
Projects
None yet
Development

No branches or pull requests

5 participants