/**
  * Get a PageView analytics object
  * @return Analytics object
  */
 public function pageViewAnalytics($url = "", $title = "")
 {
     $result = null;
     $analytics = $this->analytics();
     if ($analytics) {
         if ($url == "") {
             $url = craft()->request->url;
         }
         /* -- We want to send just a path to GA for page views */
         if (UrlHelper::isAbsoluteUrl($url)) {
             $urlParts = parse_url($url);
             if (isset($urlParts['path'])) {
                 $url = $urlParts['path'];
             } else {
                 $url = "/";
             }
             if (isset($urlParts['query'])) {
                 $url = $url . "?" . $urlParts['query'];
             }
         }
         /* -- We don't want to send protocol-relative URLs either */
         if (UrlHelper::isProtocolRelativeUrl($url)) {
             $url = substr($url, 1);
         }
         /* -- Strip the query string if that's the global config setting */
         $settings = craft()->plugins->getPlugin('instantanalytics')->getSettings();
         if (isset($settings) && isset($settings['stripQueryString']) && $settings['stripQueryString']) {
             $url = UrlHelper::stripQueryString($url);
         }
         /* -- Prepare the Analytics object, and send the pageview */
         $analytics->setDocumentPath($url)->setDocumentTitle($title);
         $result = $analytics;
         InstantAnalyticsPlugin::log("Created sendPageView for `" . $url . "` - `" . $title . "`", LogLevel::Info, false);
     }
     return $result;
 }
Exemplo n.º 2
0
 public function getFullyQualifiedUrl($url)
 {
     $result = $url;
     if (!isset($result) || $result == "") {
         return $result;
     }
     $srcUrlParts = parse_url($result);
     if (UrlHelper::isAbsoluteUrl($url) || UrlHelper::isProtocolRelativeUrl($url)) {
         /* -- The URL is already a fully qualfied URL, do nothing */
     } else {
         $siteUrlOverride = craft()->config->get("siteUrlOverride", "seomatic");
         if ($siteUrlOverride) {
             $siteUrl = $siteUrlOverride;
         } else {
             $siteUrl = craft()->getSiteUrl();
         }
         $urlParts = parse_url($siteUrl);
         $port = "";
         if (isset($urlParts['port'])) {
             $port = ":" . $urlParts['port'];
         }
         if (isset($urlParts['scheme']) && isset($urlParts['host'])) {
             $siteUrl = $urlParts['scheme'] . "://" . $urlParts['host'] . $port . "/";
         } else {
             $siteUrl = "/";
         }
         if ($siteUrl[strlen($siteUrl) - 1] == '/' && $result[0] == '/') {
             $siteUrl = rtrim($siteUrl, '/');
         }
         $result = $siteUrl . $result;
     }
     return $result;
 }