本文整理汇总了PHP中Piwik\Piwik::getJavascriptCode方法的典型用法代码示例。如果您正苦于以下问题:PHP Piwik::getJavascriptCode方法的具体用法?PHP Piwik::getJavascriptCode怎么用?PHP Piwik::getJavascriptCode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Piwik\Piwik
的用法示例。
在下文中一共展示了Piwik::getJavascriptCode方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getJavascriptTag
/**
* Returns the javascript tag for the given idSite.
* This tag must be included on every page to be tracked by Piwik
*
* @param int $idSite
* @param string $piwikUrl
* @param bool $mergeSubdomains
* @param bool $groupPageTitlesByDomain
* @param bool $mergeAliasUrls
* @param bool $visitorCustomVariables
* @param bool $pageCustomVariables
* @param bool $customCampaignNameQueryParam
* @param bool $customCampaignKeywordParam
* @param bool $doNotTrack
* @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, $disableCookies = false)
{
Piwik::checkUserHasViewAccess($idSite);
if (empty($piwikUrl)) {
$piwikUrl = SettingsPiwik::getPiwikUrl();
}
$piwikUrl = Common::sanitizeInputValues($piwikUrl);
$htmlEncoded = Piwik::getJavascriptCode($idSite, $piwikUrl, $mergeSubdomains, $groupPageTitlesByDomain, $mergeAliasUrls, $visitorCustomVariables, $pageCustomVariables, $customCampaignNameQueryParam, $customCampaignKeywordParam, $doNotTrack, $disableCookies);
$htmlEncoded = str_replace(array('<br>', '<br />', '<br/>'), '', $htmlEncoded);
return $htmlEncoded;
}
示例2: trackingCode
/**
* Installation Step 7: Display JavaScript tracking code
*/
public function trackingCode()
{
$this->checkPiwikIsNotInstalled();
$this->markInstallationAsCompleted();
$view = new View('@Installation/trackingCode', $this->getInstallationSteps(), __FUNCTION__);
$siteName = Common::unsanitizeInputValue($this->getParam('site_name'));
$idSite = $this->getParam('site_idSite');
// Load the Tracking code and help text from the SitesManager
$viewTrackingHelp = new \Piwik\View('@SitesManager/_displayJavascriptCode');
$viewTrackingHelp->displaySiteName = $siteName;
$viewTrackingHelp->jsTag = Piwik::getJavascriptCode($idSite, Url::getCurrentUrlWithoutFileName());
$viewTrackingHelp->idSite = $idSite;
$viewTrackingHelp->piwikUrl = Url::getCurrentUrlWithoutFileName();
$view->trackingHelp = $viewTrackingHelp->render();
$view->displaySiteName = $siteName;
$view->displayfirstWebsiteSetupSuccess = true;
$view->showNextStep = true;
return $view->render();
}
示例3: displayJavascriptCode
/**
* Displays the admin UI page showing all tracking tags
* @return string
*/
function displayJavascriptCode()
{
$idSite = Common::getRequestVar('idSite');
Piwik::checkUserHasViewAccess($idSite);
$jsTag = Piwik::getJavascriptCode($idSite, SettingsPiwik::getPiwikUrl());
$view = new View('@SitesManager/displayJavascriptCode');
$this->setBasicVariablesView($view);
$view->idSite = $idSite;
$site = new Site($idSite);
$view->displaySiteName = $site->getName();
$view->jsTag = $jsTag;
return $view->render();
}
示例4: displayJavascriptCode
/**
* Displays the admin UI page showing all tracking tags
* @return string
*/
function displayJavascriptCode()
{
$idSite = Common::getRequestVar('idSite');
Piwik::checkUserHasViewAccess($idSite);
$jsTag = Piwik::getJavascriptCode($idSite, SettingsPiwik::getPiwikUrl());
$site = new Site($idSite);
return $this->renderTemplate('displayJavascriptCode', array('idSite' => $idSite, 'displaySiteName' => $site->getName(), 'jsTag' => $jsTag));
}
示例5: testJavascriptTrackingCode_withAllOptions
/**
* Tests the generated JS code
* @group Core
*/
public function testJavascriptTrackingCode_withAllOptions()
{
$jsTag = Piwik::getJavascriptCode($idSite = 1, $piwikUrl = 'http://localhost/piwik', $mergeSubdomains = true, $groupPageTitlesByDomain = true, $mergeAliasUrls = true, $visitorCustomVariables = array(array("name", "value"), array("name 2", "value 2")), $pageCustomVariables = array(array("page cvar", "page cvar value")), $customCampaignNameQueryParam = "campaignKey", $customCampaignKeywordParam = "keywordKey", $doNotTrack = true);
$expected = "<!-- Piwik -->\n<script type="text/javascript">\n var _paq = _paq || [];\n _paq.push([\"setDocumentTitle\", document.domain + \"/\" + document.title]);\n // you can set up to 5 custom variables for each visitor\n _paq.push([\"setCustomVariable\", 1, \"name\", \"value\", \"visit\"]);\n _paq.push([\"setCustomVariable\", 2, \"name 2\", \"value 2\", \"visit\"]);\n // you can set up to 5 custom variables for each action (page view, download, click, site search)\n _paq.push([\"setCustomVariable\", 1, \"page cvar\", \"page cvar value\", \"page\"]);\n _paq.push([\"setCampaignNameKey\", \"campaignKey\"]);\n _paq.push([\"setCampaignKeywordKey\", \"keywordKey\"]);\n _paq.push([\"setDoNotTrack\", true]);\n _paq.push(['trackPageView']);\n _paq.push(['enableLinkTracking']);\n (function() {\n var u="//localhost/piwik/";\n _paq.push(['setTrackerUrl', u+'piwik.php']);\n _paq.push(['setSiteId', 1]);\n var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];\n g.type='text/javascript'; g.async=true; g.defer=true; g.src=u+'piwik.js'; s.parentNode.insertBefore(g,s);\n })();\n</script>\n<noscript><p><img src="//localhost/piwik/piwik.php?idsite=1" style="border:0;" alt="" /></p></noscript>\n<!-- End Piwik Code -->\n";
$this->assertEquals($expected, $jsTag);
}
示例6: trackingCode
/**
* Installation Step 8: Display JavaScript tracking code
*/
public function trackingCode()
{
$this->checkPreviousStepIsValid(__FUNCTION__);
$view = new View('@Installation/trackingCode', $this->getInstallationSteps(), __FUNCTION__);
$this->skipThisStep(__FUNCTION__);
if (!isset($this->session->firstWebsiteSetupSuccessMessage)) {
$view->displayfirstWebsiteSetupSuccess = true;
$this->session->firstWebsiteSetupSuccessMessage = true;
}
$siteName = $this->session->site_name;
$idSite = $this->session->site_idSite;
// Load the Tracking code and help text from the SitesManager
$viewTrackingHelp = new \Piwik\View('@SitesManager/_displayJavascriptCode');
$viewTrackingHelp->displaySiteName = $siteName;
$viewTrackingHelp->jsTag = Piwik::getJavascriptCode($idSite, Url::getCurrentUrlWithoutFileName());
$viewTrackingHelp->idSite = $idSite;
$viewTrackingHelp->piwikUrl = Url::getCurrentUrlWithoutFileName();
$view->trackingHelp = $viewTrackingHelp->render();
$view->displaySiteName = $siteName;
$view->showNextStep = true;
$this->session->currentStepDone = __FUNCTION__;
return $view->render();
}