Kentco在转发器中使用的分析数据

时间:2016-05-03 19:05:41

标签: kentico

是否可以利用内置的分析数据让转发器显示前10个访问过的网页/网址?

理想情况下,我会在转发器中显示给定页面类型的前5位。

4 个答案:

答案 0 :(得分:1)

在Kentico中,数据库表中存在所有内容,因此如果信息存在于此,您可以使用带有自定义查询的Repeater并编写SQL查询以获得所需内容,并将其重复显示在页面上!我将使用SQL管理工作室连接到数据库,然后四处寻找,看看你能找到你想要的东西

答案 1 :(得分:0)

使用报告模块怎么样? 转到报告> 网站分析> 网页浏览量并选择所需的报告。然后,您可以使用报告Web部件在实时站点上显示您的数据,例如。 报告图表报告表。您可以详细了解报告here

编辑:哦,我先误解了你的问题。因此,您可以将转发器与自定义查询一起使用,以根据您的偏好选择首页。您仍然可以启发报告模块,例如尝试使用以下内容:

    DECLARE @PaveViews TABLE
(
  PagePath NVARCHAR(500),
  ObjectID INT,
  Pageviews INT,
  Percents DECIMAL(10,2),
  Average INT  
)

DECLARE @Sum DECIMAL;

SET @FromDate ={%DatabaseSchema%}.Func_Analytics_DateTrim(@FromDate,'year');
SET @ToDate ={%DatabaseSchema%}.Func_Analytics_EndDateTrim(@ToDate,'year');

SELECT @Sum =   
  SUM(HitsCount)
  FROM Analytics_Statistics
  INNER JOIN Analytics_YearHits ON Analytics_YearHits.HitsStatisticsID = Analytics_Statistics.StatisticsID
  LEFT JOIN View_CMS_Tree_Joined ON View_CMS_Tree_Joined.NodeID = Analytics_Statistics.StatisticsObjectID  AND StatisticsObjectCulture = DocumentCulture
  WHERE (StatisticsSiteID = @CMSContextCurrentSiteID)
  AND (StatisticsCode=@CodeName)
  AND (HitsStartTime >= @FromDate)
 AND (HitsEndTime <= @ToDate)

INSERT INTO @PaveViews (PagePath,ObjectID,PageViews,Percents)
  SELECT TOP 100 StatsWithPath.NodeAliasPath, StatsWithPath.ObjectID, SUM(StatsWithPath.HitsCount) AS PageViews, (SUM(StatsWithPath.HitsCount)/@Sum)*100 AS Percents FROM
  (
    SELECT
     -- When NodeAliasPath is empty, use value from StatisticsObjectName instead. This could happed for example when document does not longer exist in one of the cultures.
     -- In this case row can't be joined with View_CMS_Tree_Joined.
     CASE
      WHEN NodeAliasPath = '' OR NodeAliasPath IS NULL THEN StatisticsObjectName
      ELSE NodeAliasPath
     END AS NodeAliasPath, StatisticsObjectID AS ObjectID, HitsCount 
     FROM Analytics_Statistics
     INNER JOIN Analytics_YearHits ON Analytics_YearHits.HitsStatisticsID = Analytics_Statistics.StatisticsID
     LEFT JOIN View_CMS_Tree_Joined ON Analytics_Statistics.StatisticsObjectID = View_CMS_Tree_Joined.NodeID AND StatisticsObjectCulture = DocumentCulture
     WHERE (StatisticsSiteID = @CMSContextCurrentSiteID) AND (HitsStartTime >= @FromDate) AND (HitsEndTime <= @ToDate) AND (StatisticsCode = @CodeName)
  ) AS StatsWithPath
  GROUP BY StatsWithPath.NodeAliasPath, StatsWithPath.ObjectID
  ORDER BY PageViews DESC

 UPDATE @PaveViews SET Average = (SELECT SUM(HitsValue)/SUM(HitsCount) FROM Analytics_YearHits JOIN
      Analytics_Statistics ON HitsStatisticsID = StatisticsID
      WHERE HitsStartTime >= @FromDate AND HitsEndTime <= @ToDate AND StatisticsObjectID = objectID
        AND StatisticsCode ='avgtimeonpage' AND StatisticsSiteID = @CMSContextCurrentSiteID
       )

 SELECT PagePath AS '{$reports_pageviews_Year.path_header$}',pageviews AS  '{$reports_pageviews_Year.hits_header$}',
      CAST (Percents AS NVARCHAR(10))+'%' AS '{$reports_pageviews.percent_header$}', ISNULL(CONVERT(varchar, DATEADD(s, average, 0), 108),'00:00:00') AS '{$reports_pageviews.average$}'

   FROM @PaveViews ORDER BY PageViews DESC

用于去年的网页浏览量(从网页浏览量中提取 - 年度报告)。

答案 2 :(得分:0)

您可以将“报告表格”窗口小部件添加到您的页面,然后选择TOP 10页面报告,它将显示在您的页面上。如果您不想要前10页,请进入报告模块,找到TOP 10报告,并在名为TOP 5的表格部分添加另一个查询,对其进行修改并保存。然后返回到您的小部件并选择新报告。

答案 3 :(得分:0)

这里的答案是正确的。但是,如果您想要更简单一些,请尝试将以下查询与带有自定义查询的转发器结合使用。此查询将为您提供特定站点上有史以来最常访问的10个文档。如果需要,您可以进一步调整此查询以更好地满足您的需求。

select top 10 s.StatisticsObjectName,SUM(m.HitsCount) as TotalHits from Analytics_MonthHits as m left join Analytics_Statistics as s on m.HitsStatisticsID = s.StatisticsID where s.StatisticsCode = 'pageviews' AND s.StatisticsSiteID = 1 group by s.StatisticsObjectName order by TotalHits desc

如果您还希望根据页面类型过滤结果,则需要进一步加入,例如View_CMS_Tree_Joined视图。一个让你只有cms.menuitem&#39;页面如下:

select top 10 s.StatisticsObjectName,SUM(m.HitsCount) as TotalHits from Analytics_MonthHits as m left join Analytics_Statistics as s on m.HitsStatisticsID = s.StatisticsID left join View_CMS_Tree_Joined as t on s.StatisticsObjectID = t.DocumentID  where s.StatisticsCode = 'pageviews' AND t.ClassName = 'cms.menuitem' AND s.StatisticsSiteID = 1 group by s.StatisticsObjectName order by TotalHits desc

我还建议在SQL管理工作室中尝试此查询,以便您可以看到它是如何工作的以及您获得的结果。

此外,您还可以使用报表,报表图或报表网页部件来显示一些内置报表。