diff options
author | Matthieu Aubry <matt@piwik.org> | 2014-10-06 05:25:13 +0400 |
---|---|---|
committer | Matthieu Aubry <matt@piwik.org> | 2014-10-06 05:25:13 +0400 |
commit | c9dafda0d21a7f8bf4b657c9f9d651f3ec545827 (patch) | |
tree | 682d786825ff1c17e33fad46e25c9c706c8dbd6d /core | |
parent | 527a1c4dd01b8686d7d1aa931be49125bc51007b (diff) | |
parent | 20d509aac3fcb97efb8c34f3e0c8594f5f16d28f (diff) |
Merge pull request #6380 from czolnowski/extend-tracking-code-clean
Let plugins further extend tracking code via Event 'Piwik.getJavascriptCode'
Diffstat (limited to 'core')
-rw-r--r-- | core/Piwik.php | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/core/Piwik.php b/core/Piwik.php index 16f50f387f..13124728f9 100644 --- a/core/Piwik.php +++ b/core/Piwik.php @@ -142,6 +142,7 @@ class Piwik // Build optional parameters to be added to text $options = ''; + $optionsBeforeTrackerUrl = ''; if ($groupPageTitlesByDomain) { $options .= ' _paq.push(["setDocumentTitle", document.domain + "/" + document.title]);' . PHP_EOL; } @@ -187,7 +188,9 @@ class Piwik $codeImpl = array( 'idSite' => $idSite, 'piwikUrl' => Common::sanitizeInputValue($piwikUrl), - 'options' => $options + 'options' => $options, + 'optionsBeforeTrackerUrl' => $optionsBeforeTrackerUrl, + 'protocol' => '//' ); $parameters = compact('mergeSubdomains', 'groupPageTitlesByDomain', 'mergeAliasUrls', 'visitorCustomVariables', 'pageCustomVariables', 'customCampaignNameQueryParam', 'customCampaignKeywordParam', @@ -205,6 +208,10 @@ class Piwik * - **piwikUrl**: The tracker URL to use. * - **options**: A string of JavaScript code that customises * the JavaScript tracker. + * - **optionsBeforeTrackerUrl**: A string of Javascript code that customises + * the JavaScript tracker inside of anonymous function before + * adding setTrackerUrl into paq. + * - **protocol**: Piwik url protocol. * * The **httpsPiwikUrl** element can be set if the HTTPS * domain is different from the normal domain. @@ -212,7 +219,7 @@ class Piwik */ self::postEvent('Piwik.getJavascriptCode', array(&$codeImpl, $parameters)); - $setTrackerUrl = 'var u="//{$piwikUrl}/";'; + $setTrackerUrl = 'var u="' . $codeImpl['protocol'] . '{$piwikUrl}/";'; if (!empty($codeImpl['httpsPiwikUrl'])) { $setTrackerUrl = 'var u=((document.location.protocol === "https:") ? "https://{$httpsPiwikUrl}/" : "http://{$piwikUrl}/");'; |