Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Marcus 41 posts 182 karma points
    Dec 12, 2023 @ 03:32
    Marcus
    0

    How to track content accessibility

    Nice day guys.

    I have contents of Blog document type and I would like to count user access times.

    I'm using a property called View Count for the document type and increase 1 every time the template renders. The problem is I don't want the content to be published so I'm using Save (Content Service) and it makes the content status Published (spending changes) in umbraco backoffice.

    It's not good I think. Is there any solution makes this better? Because I only want to know how many times the blog requested and don't make any change for the contents

    I'm new with umbraco. Appreciate any help!

  • Marc Goodson 2148 posts 14353 karma points MVP 8x c-trib
    Dec 12, 2023 @ 11:39
    Marc Goodson
    100

    Hi Marcus

    First thought would something like this plugin do the job?

    https://marketplace.umbraco.com/package/flowcourier.umbraco.analytics

    if your site has google analytics, you can get much more information than just a count of the number of visits...

    If not, and you only want the count of views, and you only want to manage it yourself - then you should avoid saving the count value on the doc type itself. This will create a version for every single save - if a an editor uses the rollback feature of Umbraco to go back to an earlier version of the blog post - they'll also rollback the current count!

    It would be better to have a custom database table, that has columns for the pageId and the count, and then have an UmbracoApiController that could receive a request via javascript when the page is loaded, that then could update the database table with the increased count.

    You could then build a custom 'Content App' (like the 'Visitors' one in that plugin) - with your own implementation called 'Counts' or something... and then you could query the database table, (as you'll be able to retrieve the current page Id in the backoffice in angularJS)...

    If that helps give you a steer?

    regards

    Marc

  • nehakakar 14 posts 84 karma points
    Dec 12, 2023 @ 12:14
    nehakakar
    0

    Use a separate database table for storing view counts and update it on each page load. Avoid using the content service's save method instead increment view counts through server-side logic or API calls when a blog page is requested.

  • Marcus 41 posts 182 karma points
    Dec 13, 2023 @ 02:36
    Marcus
    0

    Thank you all !

Please Sign in or register to post replies

Write your reply to:

Draft