Expand my Community achievements bar.

SOLVED

How to get page read duration time in AEM?

Avatar

Level 8

I want to get page read duration time for aem pages. I am planning to get the total number of words on the page and divide them by 240 to get an approximate page read time. Planning to consider image and video read time, for image it is 7S and for video it is 40s.

I am looking for a solution to get numbers of words on a page. Is there any way in AEM to get this number of words? Basically I need to traverse to all components and get the text and calculate the number of words.

1 Accepted Solution

Avatar

Correct answer by
Level 4

I am not very familiar with Adobe Analytics, but reading the documentation it seems to be a feature:

https://experienceleague.adobe.com/docs/analytics/components/dimensions/time-spent-on-page.html?lang... 

View solution in original post

8 Replies

Avatar

Community Advisor

@Mario248 if you are looking for medium style to display read time of a blog/article, I would recommend to go with Javascript plugin instead of doing this at AEM, which I feel very cumbersome and unnecessary to reinvent wheel.

 

https://www.npmjs.com/package/reading-time

Avatar

Level 8

Thanks for your input. I am planning to do this in server side. Is there any utility available for java?

Avatar

Level 4

You should do this via JavaScript in the Frontend.

 

You can ship that JavaScript code with either Clientlibs or via a ui.frontend module. You can probably find some npm packages to do this for you OOTB. Also note that web analytics tools such as Google Analytics have this built-in.

Avatar

Level 8

Do you know if this feature is available in adobe analytics ?

Avatar

Administrator

The average time on the page is available with AA. This would help If you are planning to do offline analysis but not for runtime.

See: https://experienceleague.adobe.com/docs/analytics/components/metrics/average-time-on-site.html?lang=...

 



Kautuk Sahni

Avatar

Administrator

Option 1:

I would recommend if functionality is really needed, why not assign a time unit "T" for each word/Alphabet and calculate the estimated time required to read by multiplying T by the number of words. I know this is an approximation value to the original Question. 

 

Option 2:

Use AA to capture the time on the page. And Weekly/Biweekly use this value from AA and insert this into the AEM system. 

 

Option3: 

You have to build the whole custom logic for this. You can implement the average time spent on a page without using a dedicated analytics tool, although it will require more custom development work. Here is an alternative approach using JavaScript and a server-side logic:

  1. Client-Side JavaScript:

    First, you'll need to track user interactions on your blog post pages using client-side JavaScript. You can do this by creating a custom script to record the time a user spends on a page and send this data to your server. Here's a simplified example:

    // JavaScript on your blog post pages let startTime = new Date().getTime(); // Listen for the 'unload' event to track when the user leaves the page window.addEventListener('beforeunload', function () { let endTime = new Date().getTime(); let timeSpentOnPage = (endTime - startTime) / 1000; // in seconds // Send the timeSpentOnPage to your server via an HTTP request fetch('/track-time', { method: 'POST', body: JSON.stringify({ page: 'blog-post-slug', timeSpent: timeSpentOnPage }), headers: { 'Content-Type': 'application/json', }, }); });
  2. Server-Side Code:

    On your server, you need to handle the incoming data from the client and store it in a data structure like a database or a memory cache. You'll also calculate the average time spent on each blog post page. 

  3. Displaying Average Time:

    Finally, you can retrieve the average time spent on each blog post page by making a request to the  API endpoint and displaying it on your webpage.

You have to adapt this Logic to accommodate this within the AEM. But, do retrospect do you want to implement this on your own or 



Kautuk Sahni

Avatar

Correct answer by
Level 4

I am not very familiar with Adobe Analytics, but reading the documentation it seems to be a feature:

https://experienceleague.adobe.com/docs/analytics/components/dimensions/time-spent-on-page.html?lang... 

Avatar

Administrator

@Mario248 Do you find the suggestions from Users useful? Please let us know if more information is required. Otherwise, please mark the answer as correct for posterity.



Kautuk Sahni