View Counter:field: Any Entity Type

Created on 24 July 2023, over 1 year ago
Updated 17 September 2024, 2 months ago

Problem/Motivation

Modern Drupal sites have more entities than just Nodes. Most entities do not have a links region.

Steps to reproduce

Proposed resolution

Add a pseudo field to all entities who's views are being counted.

Remaining tasks

User interface changes

Settings Form will contain options for other Entity Types.

API changes

Data model changes

πŸ“Œ Task
Status

Active

Version

2.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States bluegeek9

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @bluegeek9
  • πŸ‡ΉπŸ‡­Thailand AlfTheCat

    This would be really great to have, I have a site that would really benefit from the ability to show users the views of all their entities (products and taxonomy terms). Right now, if reporting only node views, the stats would be greatly under reported.

    If we could include a pseudo field to a view mode or views display it would be fantastic.

  • πŸ‡©πŸ‡ͺGermany kreatIL

    I maintain a Drupal site with around 30,000 media entities, which constitute approximately 95% of our content. The Visitors module would be incredibly useful for us to track and analyze user interactions with this content.

    I appreciate the discussion here about extending entity types, and I want to echo the value of this enhancement. Supporting media entities would allow us to gain detailed insights into user engagement across all content types, making Visitors a powerful tool for a wider range of Drupal sites.

  • πŸ‡ΊπŸ‡ΈUnited States bluegeek9

    Hi,

    The code already supports recording additional entity types. The issue I ran into was how to display the view count. Nodes have a links region. Links is where the Statistics project displays the view count. Other entity types do not necessarily have links. I try a pseudo field but it did not look good.

    How would you want to show the view count for a Media entity?

    You might be able to accomplish some of what you need with the views plugins introduced in 8.x-2.20.

  • πŸ‡ΉπŸ‡­Thailand AlfTheCat

    If we could leverage views it would already be great because the https://www.drupal.org/project/viewfield β†’ module could then allow it to be added to any view mode of any entity.

  • πŸ‡ΊπŸ‡ΈUnited States bluegeek9

    @alfthecat,

    The code supports views.

    Suppose you edit visitors.config and add the entity types to counter.entity_types, it will count the visits and you will be able to access the count in views. There is not an option in the settings to add the entity types. You well need to do it manually.

  • πŸ‡ΉπŸ‡­Thailand AlfTheCat

    Hi @bluegeek, thanks for clarifying that.

    One additional thought I had based on this conversation, is that in some cases (like my marketplace), it would be very valuable if we could track impressions by viewmode or a view.

    If we could then build reporting views and display statistics by view mode, it would open up the possibility of offering the boosting of posts, user profiles, and other forms of content promotion to the site's users. If the site sells ad space, this would be vital.

    Just a thought, not sure if a psuedo field would be the way to go but I imagine adding it to a view mode to initiate tracking might be handy and intuitive for site builers.

  • πŸ‡ΊπŸ‡ΈUnited States bluegeek9

    @alfthecat,

    Does the view mode correspond to a URL?

    Display views, or Form Views, or both?

    Are the ads in Blocks?

  • πŸ‡ΉπŸ‡­Thailand AlfTheCat

    Hi @bluegeek,

    The example I'm thinking of, and the kind of site I'm referring to, is like one of those food delivery platforms (it can apply to any kind of directory and marketplace). Let's say each restaurant has a page and they add their menu items as commerce products. Both the restaurant nodes and the commerce products leverage view modes. The restaurant nodes would have a viewmode for "full view" and "ad". The products would have a "full view" and "catalog" viewmode, the latter styled for display in a typical catalog grid.

    To restaurant owners, it would be useful to see how often their dishes were shown to users on the site, which would be the "catalog" view mode. Also, restaurant owners might want to boost their page at a fee, so then it would be necessary to report how often their restaurant node's "ad" viewmode was served to users of the site.

    Adding a psuedo-field to the entity, maybe one for each viewmode, would be an easy way to add a segmented "counter" to entities and views for site builders. Maybe there's a better approach, but I think this kind of reporting would be very valuable for this kind of platform.

    I currently display a footnote under the user's visitor count stating it doesn't include product views or views in recommender views distributed across the site and am not able to provide a "boosting" feature because there would be no way of reporting the results.

  • πŸ‡ΊπŸ‡ΈUnited States bluegeek9

    alfthecat,

    Tracking impressions might be something that can be done with 'Visitors Actions'.

    ✨ Visitor Actions Active

  • πŸ‡ΉπŸ‡­Thailand AlfTheCat

    Thanks! That will be very interesting!

Production build 0.71.5 2024