Merge branch 'master' into 0.9.x
This commit is contained in:
commit
e25d4683c8
@ -78,20 +78,28 @@ class PiwikAnalyticsPlugin extends Plugin
|
|||||||
*/
|
*/
|
||||||
function onEndShowScripts($action)
|
function onEndShowScripts($action)
|
||||||
{
|
{
|
||||||
$piwikCode1 = <<<ENDOFPIWIK
|
// Slight modification to the default code.
|
||||||
var pkBaseURL = (("https:" == document.location.protocol) ? "https://{$this->piwikroot}" : "http://{$this->piwikroot}");
|
// Loading the piwik.js file from a <script> created in a document.write
|
||||||
document.write(unescape("%3Cscript src='" + pkBaseURL + "piwik.js' type='text/javascript'%3E%3C/script%3E"));
|
// meant that the browser had no way to preload it, ensuring that its
|
||||||
ENDOFPIWIK;
|
// loading will be synchronous, blocking further page rendering.
|
||||||
$piwikCode2 = <<<ENDOFPIWIK
|
//
|
||||||
|
// User-agents understand protocol-relative links, so instead of the
|
||||||
|
// URL produced in JS we can just give a universal one. Since it's
|
||||||
|
// sitting there in the DOM ready to go, the browser can preload the
|
||||||
|
// file for us and we're less likely to have to wait for it.
|
||||||
|
$piwikUrl = '//' . $this->piwikroot . 'piwik.js';
|
||||||
|
$piwikCode = <<<ENDOFPIWIK
|
||||||
try {
|
try {
|
||||||
|
var pkBaseURL = (("https:" == document.location.protocol) ? "https://{$this->piwikroot}" : "http://{$this->piwikroot}");
|
||||||
var piwikTracker = Piwik.getTracker(pkBaseURL + "piwik.php", {$this->piwikId});
|
var piwikTracker = Piwik.getTracker(pkBaseURL + "piwik.php", {$this->piwikId});
|
||||||
piwikTracker.trackPageView();
|
piwikTracker.trackPageView();
|
||||||
piwikTracker.enableLinkTracking();
|
piwikTracker.enableLinkTracking();
|
||||||
} catch( err ) {}
|
} catch( err ) {}
|
||||||
ENDOFPIWIK;
|
ENDOFPIWIK;
|
||||||
|
|
||||||
$action->inlineScript($piwikCode1);
|
// Don't use $action->script() here; it'll try to preface the URL.
|
||||||
$action->inlineScript($piwikCode2);
|
$action->element('script', array('type' => 'text/javascript', 'src' => $piwikUrl), ' ');
|
||||||
|
$action->inlineScript($piwikCode);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user