The other day we had to create a summary of visits to a specific SharePoint list to see the trends as new items have been published. The hits must be aggregated by the calendar week. To achieve that goal we run the following query on the Web Analytics Reporting database, then exported the results into Excel and created a Pivot table for further processing by business users.
SELECT
assets.Title,
DATEPART(YEAR, CONVERT(DATETIME, CONVERT(CHAR(8), clicks.DateId))) AS Year,
DATEPART(ISOWK, CONVERT(DATETIME, CONVERT(CHAR(8), clicks.DateId))) AS WeekOfYear,
SUM(clicks.Frequency) AS ClickCount
FROM [Web Analytics Reporting].[dbo].[WAClickAggregationByDate] clicks
inner join [Web Analytics Reporting].[dbo].[WAAssetMetadata] assets
on clicks.ClickedAssetIdHash = assets.AssetIdHash
WHERE assets.AssetId like ‘http://yoursite/Lists/listname/dispform%’
GROUP BY assets.Title, DATEPART(YEAR, CONVERT(DATETIME, CONVERT(CHAR(8), clicks.DateId))), DATEPART(ISOWK, CONVERT(DATETIME, CONVERT(CHAR(8), clicks.DateId)))
ORDER BY Year DESC, WeekOfYear DESC, ClickCount DESC
Note: In this report we assumed that the title of the item is unique!
Leave a comment