Viewing Total Downloads in a Transformation

Mike Bilz asked on June 17, 2020 00:47

Hello Kentico Team,

You all helped me put together a tool recently that can track total page views in the last month and the last year using the WebAnalytics API:

<%# CMS.WebAnalytics.HitsInfoProvider.GetObjectHitCount(
CMS.SiteProvider.SiteContext.CurrentSiteID,
EvalInteger("NodeID"),
CMS.WebAnalytics.HitsIntervalEnum.Month, 
"pageviews", 
DateTime.Now.AddDays(-60), 
DateTime.Now) %>

However, this same code does not return any information when applied to CMSFile items. Is there a similar API I can use in a transformation to get the number of downloads for a file in the tree? Total downloads is fine, but being able to adjust it by a date range like in the example above would be ideal.

Thanks in advance.

-mike

Correct Answer

Juraj Ondrus answered on June 19, 2020 06:57

Well, you already posted the code you are using to get a report and that method hold one parameter code name - which is the code name of the report. Have you tried changing the code name of the report and replace it with the code name of the file downloads report?
So, instead of pageviews use filedownlaods.

0 votesVote for this answer Unmark Correct answer

Recent Answers


Juraj Ondrus answered on June 17, 2020 07:40

Habe you tried changing the code name of the report to be the file download report? (e.g. filedownloads.monthreport)

0 votesVote for this answer Mark as a Correct answer

Mike Bilz answered on June 19, 2020 00:11

Hi Juraj,

Could you provide some more information about this, or maybe a link to the API you are referencing. Googling "filedownloads.monthreport" only brings up this discussion.

Thanks.

-mike

0 votesVote for this answer Mark as a Correct answer

Mike Bilz answered on June 19, 2020 23:13

Thank you Juraj, that appears to have done the trick.

By the way, is this API anywhere on the DevNet site? It's really useful stuff, and I'd love to play with it some more for future reporting projects.

Thanks again.

0 votesVote for this answer Mark as a Correct answer

Juraj Ondrus answered on June 22, 2020 06:10

The API documentation is available here. But in this case, it was rather of changing the parameter values - the report code name. You can find the report code nemae if you will go to Reporting app -> Web analytics reports and edit desired report. Then, on the General tab you can see its code name.

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.