Select to view content in your preferred language

Portal items- number of views

6340
13
05-02-2018 09:47 PM
JosephJose
Occasional Contributor

Somewhere in conversation, I came across a json url which gives me the number of views on the particular item be it a webmap, app, kml.

Have lost it .Can someone point me out correctly?

Is it something that only an admin can do?

13 Replies
XanderBakker
Esri Esteemed Contributor

Each item in portal has a property "numViews":

Item—ArcGIS REST API: Users, groups, and content | ArcGIS for Developers 

See an example using Python to get the items sorted by the number of views (at the bottom of the page):

Example: Update the URL of a service in a web map—Portal for ArcGIS (10.6) | ArcGIS Enterprise  

I guess you will need to have access to the items to be able to retrieve the properties.

JosephJose
Occasional Contributor

That's near to what I wanted. We have few items not worth running a script.

Can you give me the Url that returns me the number of items in html , json formats? You know something like <portal>.arcgis.com\sharing\rest\....\....\ where I can view the output

0 Kudos
JosephJose
Occasional Contributor

why do certain people come and just post in answers not even fully understanding the question? Everyone here isn't looking for APIs though it's a good medium

JonathanQuinn
Esri Notable Contributor

Anything you're looking at in the Portal home app is driven from an API...

Anyway, you can use the home app to find the number of views:

https://<portal>.<domain>.com/portal/home/item.html?id=<itemID>

Or users content within Sharing API that the home app is getting its information from:

https://<portal>.<domain>.com/portal/sharing/rest/content/users/<user>/items/<itemID>

Or by searching in the home app:

Or by searching in the Sharing API, which is what searching in the Sharing API is giving you:

BorjaParés_Fuente
Emerging Contributor

Hi all,

is it possible to retrieve the numviews property filtered by user? I mean, is there any log where I could find the items viewed by a user?

Thanks in advance.

AdrienComp
Emerging Contributor

Hello @BorjaParés_Fuente , 

I came across your comment and this is exactly one of the things I am currently trying to achieve! This was three years ago, but maybe you remember how you solved this? Thanks for any tip you might have. 

0 Kudos
ClayGrant
New Contributor

Xander,

   Is it possible to reset the numViews value back to zero? 

0 Kudos
ToddW_stl
Esri Contributor

Note:  Exercise extreme caution when connecting to Portal's PostgreSQL database.

A colleague and I just tested and confirmed we can modify the numViews value via Portal's PostgresSQL database.  Our use case was publishing new Mobile Map Packages with new names, but we wanted to preserve the legacy file Number of Downloads (which is numViews when accessed via API).

  • installed pgAdmin on portal machine
  • add/register new server connection to portal's database called "gwdb"
    • Host name: localhost (or IP address if you're not on the portal machine)
    • Port: 7654
    • Maintenance database: gwdb
    • Username: portaladmin
    • Password: <portaladmin password>
  • drill down to gw_items table
    • gwdb  ->  Schemas  ->  public  ->  Tables  ->  gw_items

  • right-click on gw_items to View/Edit Data (I chose first 100 rows to access the SQL query used)
  • update SQL query to find item via specific keyword in item title
    • SELECT * FROM public.gw_items WHERE item LIKE '%keyword%'
  • scroll over to "num_views" column and edit the integer value
  • click Save Data Changes (or F6)
  • refresh item details page in portal to confirm

I'll note this again below, for good measure. 😊

Note:  Exercise extreme caution when connecting to Portal's PostgreSQL database.

0 Kudos
TimothyMichael
Frequent Contributor

Using the ArcGIS API for Python you can do the following:

import arcgis
from arcgis.gis import GIS

# Org URL
url = "https://nation.maps.arcgis.com"

# Make a connection to the portal
gis = GIS(url=url)

# Item ID
# Using a public story map for this example
# https://nation.maps.arcgis.com/apps/Cascade/index.html?appid=e4ae5b57cf9045288909a93cc31cde7c
item = "e4ae5b57cf9045288909a93cc31cde7c"

i = gis.content.get(item)
print(i['numViews'])‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍