Skip to content
Extraits de code Groupes Projets
Valider 9bbab618 rédigé par sgiehl's avatar sgiehl
Parcourir les fichiers

refs #6174 - added possibility to add 'disableCookies' option in tracking code generator

parent 25545fdc
Branches
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -131,7 +131,7 @@ class Piwik
public static function getJavascriptCode($idSite, $piwikUrl, $mergeSubdomains = false, $groupPageTitlesByDomain = false,
$mergeAliasUrls = false, $visitorCustomVariables = false, $pageCustomVariables = false,
$customCampaignNameQueryParam = false, $customCampaignKeywordParam = false,
$doNotTrack = false)
$doNotTrack = false, $disableCookies = false)
{
// changes made to this code should be mirrored in plugins/CoreAdminHome/javascripts/jsTrackingGenerator.js var generateJsCode
$jsCode = file_get_contents(PIWIK_INCLUDE_PATH . "/plugins/Morpheus/templates/javascriptCode.tpl");
......@@ -182,6 +182,9 @@ class Piwik
if ($doNotTrack) {
$options .= ' _paq.push(["setDoNotTrack", true]);' . PHP_EOL;
}
if ($disableCookies) {
$options .= ' _paq.push(["disableCookies"]);' . PHP_EOL;
}
$codeImpl = array(
'idSite' => $idSite,
......
......@@ -161,7 +161,8 @@
pageCustomVariables: getCustomVariables('javascript-tracking-page-cv'),
customCampaignNameQueryParam: null,
customCampaignKeywordParam: null,
doNotTrack: $('#javascript-tracking-do-not-track').is(':checked') ? 1 : 0
doNotTrack: $('#javascript-tracking-do-not-track').is(':checked') ? 1 : 0,
disableCookies: $('#javascript-tracking-disable-cookies').is(':checked') ? 1 : 0
};
if ($('#custom-campaign-query-params-check').is(':checked')) {
......
......@@ -26,6 +26,8 @@
"JSTracking_CodeNote": "Make sure this code is on every page of your website before the %1$s tag.",
"JSTracking_CustomCampaignQueryParam": "Use custom query parameter names for the campaign name & keyword",
"JSTracking_CustomCampaignQueryParamDesc": "Note: %1$sPiwik will automatically detect Google Analytics parameters.%2$s",
"JSTracking_DisableCookies": "Disable all tracking cookies",
"JSTracking_DisableCookiesDesc": "Disables all first party cookies. Existing Piwik cookies for this websites will be deleted on the next page view.",
"JSTracking_EnableDoNotTrack": "Enable client side DoNotTrack detection",
"JSTracking_EnableDoNotTrack_AlreadyEnabled": "Note: Server side DoNotTrack support has been enabled, so this option will have no effect.",
"JSTracking_EnableDoNotTrackDesc": "So tracking requests will not be sent if visitors do not wish to be tracked.",
......
......@@ -150,6 +150,16 @@
</div>
</div>
{# disable all cookies options #}
<div class="tracking-option-section">
<input type="checkbox" id="javascript-tracking-disable-cookies"/>
<label for="javascript-tracking-disable-cookies">{{ 'CoreAdminHome_JSTracking_DisableCookies'|translate }}</label>
<div class="small-form-description">
{{ 'CoreAdminHome_JSTracking_DisableCookiesDesc'|translate }}
</div>
</div>
{# custom campaign name/keyword query params #}
<div class="tracking-option-section">
<input class="section-toggler-link" type="checkbox" id="custom-campaign-query-params-check"
......
......@@ -69,13 +69,13 @@ class API extends \Piwik\Plugin\API
* @param bool $customCampaignNameQueryParam
* @param bool $customCampaignKeywordParam
* @param bool $doNotTrack
* @internal param $
* @param bool $disableCookies
* @return string The Javascript tag ready to be included on the HTML pages
*/
public function getJavascriptTag($idSite, $piwikUrl = '', $mergeSubdomains = false, $groupPageTitlesByDomain = false,
$mergeAliasUrls = false, $visitorCustomVariables = false, $pageCustomVariables = false,
$customCampaignNameQueryParam = false, $customCampaignKeywordParam = false,
$doNotTrack = false)
$doNotTrack = false, $disableCookies = false)
{
Piwik::checkUserHasViewAccess($idSite);
......@@ -87,7 +87,7 @@ class API extends \Piwik\Plugin\API
$htmlEncoded = Piwik::getJavascriptCode($idSite, $piwikUrl, $mergeSubdomains, $groupPageTitlesByDomain,
$mergeAliasUrls, $visitorCustomVariables, $pageCustomVariables,
$customCampaignNameQueryParam, $customCampaignKeywordParam,
$doNotTrack);
$doNotTrack, $disableCookies);
$htmlEncoded = str_replace(array('<br>', '<br />', '<br/>'), '', $htmlEncoded);
return $htmlEncoded;
}
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Veuillez vous inscrire ou vous pour commenter