Skip to content
Extraits de code Groupes Projets
Valider d8d05949 rédigé par Jesse's avatar Jesse
Parcourir les fichiers

Changed JavaScript Tracking Code generation to use "//", instead of verifying...

Changed JavaScript Tracking Code generation to use "//", instead of verifying whether the site is using "https", or not, and generating a corresponding URL.

"//" has been part of the RFC for well over 18 years. It has been confirmed to work in all major browsers (Firefox, Chrome, IE, Opera).

References:
- RFC 1808 Section 4: http://www.ietf.org/rfc/rfc1808.txt
- RFC 3986 Section 5.2: http://www.ietf.org/rfc/rfc3986.txt
- Stack Overflow QA 1: http://stackoverflow.com/q/4659345/238722
- Stack Overflow QA 2: http://stackoverflow.com/q/6785442/238722
parent 29243433
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -204,12 +204,12 @@ class Piwik
self::postEvent('Piwik.getJavascriptCode', array(&$codeImpl, $parameters));
if (!empty($codeImpl['httpsPiwikUrl'])) {
$setTrackerUrl = 'var u=(("https:" == document.location.protocol) ? "https://{$httpsPiwikUrl}/" : '
$setTrackerUrl = 'var u=((document.location.protocol === "https:") ? "https://{$httpsPiwikUrl}/" : '
. '"http://{$piwikUrl}/");';
$codeImpl['httpsPiwikUrl'] = rtrim($codeImpl['httpsPiwikUrl'], "/");
} else {
$setTrackerUrl = 'var u=(("https:" == document.location.protocol) ? "https" : "http") + "://{$piwikUrl}/";';
$setTrackerUrl = 'var u="//{$piwikUrl}/";';
}
$codeImpl = array('setTrackerUrl' => htmlentities($setTrackerUrl)) + $codeImpl;
......
......@@ -12,11 +12,11 @@ $trackingURL = Piwik_getUrlTrackPageView($idSite = 16, $customTitle = 'This titl
<script type="text/javascript">
var _paq = _paq || [];
(function() {
var u=(("https:" == document.location.protocol) ? "https" : "http") + "://localhost/piwik-master/";
var u="//localhost/piwik-master/";
_paq.push(["setTrackerUrl", u+"piwik.php"]);
_paq.push(["setSiteId", "16"]);
var d=document, g=d.createElement("script"), s=d.getElementsByTagName("script")[0]; g.type="text/javascript";
g.defer=true; g.async=true; g.src=u+"js/piwik.js"; s.parentNode.insertBefore(g,s);
var d=document, g=d.createElement("script"), s=d.getElementsByTagName("script")[0];
g.type="text/javascript"; g.async=true; g.defer=true; g.src=u+"piwik.js"; s.parentNode.insertBefore(g,s);
})();
</script>
<!-- End Piwik Code -->
......
......@@ -29,11 +29,11 @@ To run this properly you will need
```
[...]
(function() {
var u=(("https:" == document.location.protocol) ? "https" : "http") + "://trackedsite.com/";
var u="//trackedsite.com/";
_paq.push(["setTrackerUrl", u+"piwik.php"]);
_paq.push(["setSiteId", "trackedsite-id"]);
var d=document, g=d.createElement("script"), s=d.getElementsByTagName("script")[0]; g.type="text/javascript";
g.defer=true; g.async=true; g.src=u+"piwik.php"; s.parentNode.insertBefore(g,s);
var d=document, g=d.createElement("script"), s=d.getElementsByTagName("script")[0];
g.type="text/javascript"; g.async=true; g.defer=true; g.src=u+"piwik.php"; s.parentNode.insertBefore(g,s);
})();
</script>
<!-- End Piwik Code -->
......
......@@ -5,11 +5,11 @@
_paq.push(['trackPageView']);
_paq.push(['enableLinkTracking']);
(function() {
var u=((&quot;https:&quot; == document.location.protocol) ? &quot;https&quot; : &quot;http&quot;) + &quot;://example.org/piwik/&quot;;
var u=&quot;//example.org/piwik/&quot;;
_paq.push(['setTrackerUrl', u+'piwik.php']);
_paq.push(['setSiteId', 1]);
var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0]; g.type='text/javascript';
g.defer=true; g.async=true; g.src=u+'piwik.js'; s.parentNode.insertBefore(g,s);
var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
g.type='text/javascript'; g.async=true; g.defer=true; g.src=u+'piwik.js'; s.parentNode.insertBefore(g,s);
})();
&lt;/script&gt;
&lt;noscript&gt;&lt;p&gt;&lt;img src=&quot;http://example.org/piwik/piwik.php?idsite=1&quot; style=&quot;border:0;&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;&lt;/noscript&gt;
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter