public function getJavascriptTag($idSite, $piwikUrl = '', $mergeSubdomains = false, $groupPageTitlesByDomain = false,
                                     $mergeAliasUrls = false, $visitorCustomVariables = false, $pageCustomVariables = false,
                                     $customCampaignNameQueryParam = false, $customCampaignKeywordParam = false,
                                     $doNotTrack = false, $disableCookies = false, $trackNoScript = false,
                                     $crossDomain = false, $forceMatomoEndpoint = false)
    {
        Piwik::checkUserHasViewAccess($idSite);

        if (empty($piwikUrl)) {
            $piwikUrl = SettingsPiwik::getPiwikUrl();
        }

        // Revert the automatic encoding
        // TODO remove that when https://github.com/piwik/piwik/issues/4231 is fixed
        $piwikUrl = Common::unsanitizeInputValue($piwikUrl);
        $visitorCustomVariables = Common::unsanitizeInputValues($visitorCustomVariables);
        $pageCustomVariables = Common::unsanitizeInputValues($pageCustomVariables);
        $customCampaignNameQueryParam = Common::unsanitizeInputValue($customCampaignNameQueryParam);
        $customCampaignKeywordParam = Common::unsanitizeInputValue($customCampaignKeywordParam);

        $generator = new TrackerCodeGenerator();
        if ($forceMatomoEndpoint) {
            $generator->forceMatomoEndpoint();
        }

        $code = $generator->generate($idSite, $piwikUrl, $mergeSubdomains, $groupPageTitlesByDomain,
                                     $mergeAliasUrls, $visitorCustomVariables, $pageCustomVariables,
                                     $customCampaignNameQueryParam, $customCampaignKeywordParam,
                                     $doNotTrack, $disableCookies, $trackNoScript, $crossDomain);
        $code = str_replace(array('<br>', '<br />', '<br/>'), '', $code);
        return $code;
    }