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

Test new snippet without document.write on various browsers + update all docs #2517

Closed
robocoder opened this issue Jun 26, 2011 · 10 comments
Closed
Labels
Bug For errors / faults / flaws / inconsistencies etc. wontfix If you can reproduce this issue, please reopen the issue or create a new one describing it.
Milestone

Comments

@robocoder
Copy link
Contributor

If the page being tracked is XHTML Strict and being served as content type application/xhtml+xml, some browsers will disable document.write().

At present, we don't differentiate between the secure vs non-secure domains where someone hosts piwik, yet we mimick GA's tag.

I believe we should change the tracking tag to simply use the relative URI without the scheme. This is in the original standard rfc1808 (circa 1995) -- now obsolete by rfc 3986 -- and is well-supported by modern browsers (and even old ones like IE4).

  • more compact tag
  • fixes inconsistency in the noscript tag
<!-- Piwik --> 
<script src="//{$piwikUrl}piwik.js" type="text/javascript"></script>
<script type="text/javascript">
var pkBaseURL = '//{$piwikUrl}';
var piwikTracker = Piwik.getTracker(pkBaseURL + "piwik.php", {$idSite});
piwikTracker.trackPageView();
piwikTracker.enableLinkTracking();
</script>
<noscript><p><img src="//{$piwikUrl}piwik.php?idsite={$idSite}" style="border:0" alt="" /></p></noscript>
<!-- End Piwik Tracking Code -->

Note: document.write is no longer "deprecated" in html5, but the draft spec sums up why it shouldn't be used: http://dev.w3.org/html5/spec/Overview.html#dom-document-write

@mattab
Copy link
Member

mattab commented Jun 29, 2011

I have the feeling that if the GA tag contains the SSL detect logic like ours, there must be a good backward compatible reason, so I think this change has some risk involved.

Decreasing priority since this doesn't cause issues, and will not result in more functionality except for the few bytes saved in the tag.

@robocoder
Copy link
Contributor Author

It's not a compatibility issue. GA has a separate subdomain for https.

@mattab
Copy link
Member

mattab commented Jul 5, 2011

This was reported in: http://forum.piwik.org/read.php?2,78573

Would be nice to make the switch if it doesn't break with old browsers...?

@mattab
Copy link
Member

mattab commented Jul 15, 2011

we want to start advertising/pushing asynchronous tag, see #1845

What would be the asynchronous version of this change?

Probably


<!-- Piwik -->
<script type="text/javascript">
var _paq = _paq || [];
(function(){
    var u="//{$PIWIK_URL}";
    _paq.push(['setSiteId', {$IDSITE}]);

[....]

(not tested)

Also

@mattab
Copy link
Member

mattab commented Sep 16, 2011

Increasing priority since disabling document.write sounds like a very good idea in general, and so far there is no known issues? we probably should test it with Ie6, 7, older versions of FF, etc> ?

@mattab
Copy link
Member

mattab commented Jan 26, 2012

From email, bug report with document.write causing xhtml to report error in FF.

Should we fix this ticket? is it really not risky at all?


Is the Piwik Javascript Tracking Code XHTML 1.0 compatible?
Unfortunately for the file served as real XHTML errors are generated because document.write is not allowed in DOM and XHTML 1.0 and 1.1.
Made by Firefox
Error: uncaught exception: [Exception... "An attempt was made to use an object that is not, or is no longer, usable"  code: "11" nsresult: "0x8053000b (NS_ERROR_DOM_INVALID_STATE_ERR)"  location: "http://www.pecuch.info/"]
Made by Opera
[2012-01-19 14:42:27] JavaScript - http://www.pecuch.info/
Inline script thread
Uncaught exception: DOMException: INVALID_STATE_ERR
Error thrown at line 3, column 0 in http://www.pecuch.info/:
   document.write(unescape("%3Cscript src='" + pkBaseURL + "piwik.js' type='text/javascript'%3E%3C/script%3E"));

@robocoder
Copy link
Contributor Author

@robocoder
Copy link
Contributor Author

closed in error

@mattab
Copy link
Member

mattab commented Sep 19, 2012

Thanks Anthon for the great link. It is indeed a wontfix (does not work under IE6).

Also the explicit listing of the https domain is a good reminder to the user that Piwik also needs to work in SSL... so it's useful :)

@mattab
Copy link
Member

mattab commented Dec 16, 2012

Milestone 1.8.x Piwik 1.8.x deleted

@robocoder robocoder added this to the 1.12.x - Piwik 1.12.x milestone Jul 8, 2014
This issue was closed.
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. wontfix If you can reproduce this issue, please reopen the issue or create a new one describing it.
Projects
None yet
Development

No branches or pull requests

2 participants