How to include page view analytics in transformation

Mike Bilz asked on February 5, 2020 17:02

Hello Kentico Team,

Is it possible to include analytics data in a repeater transformation? Specifically I would like to include the number of page views (either total, or within a given time frame).

My goal is to create something like the following:

Page Name, Last Updated, Total Page Views

Thanks in advance.

-mike

Correct Answer

Dat Nguyen answered on February 5, 2020 20:22

Right, replace the current document NodeID with EvalInteger("NodeID")

1 votesVote for this answer Unmark Correct answer

Recent Answers


Dat Nguyen answered on February 5, 2020 19:10 (last edited on February 5, 2020 20:33)

Modify this snippet and drop it in your transformation:

<p> Hits: <%# CMS.WebAnalytics.HitsInfoProvider.GetObjectHitCount(
    CMS.SiteProvider.SiteContext.CurrentSiteID,
    EvalInteger("NodeID"), //edit
    CMS.WebAnalytics.HitsIntervalEnum.Month, 
    "pageviews", 
    DateTime.Now.AddDays(-365), 
    DateTime.Now) %> </p>

This example gets the transformed page's monthly page views over the past year.

0 votesVote for this answer Mark as a Correct answer

Mike Bilz answered on February 5, 2020 20:12

Thank you Dat,

This is fantastic. However, the "CurrentDocument" argument does not work for my use case, since that only shows the information for the page the transformation is presented on, not for the page the transformation is referencing.

Is there a way to write this to reflect the NodeID of the document the transformation is referencing? Something like Eval("NodeID")?

Thanks.

-mike

0 votesVote for this answer Mark as a Correct answer

Mike Bilz answered on February 5, 2020 20:45

Thank you Dat!

You're a wizard!

0 votesVote for this answer Mark as a Correct answer

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