Forum Discussion

Inactive User's avatar
Inactive User
7 years ago

User Metrics / User Statistics

Hello everyone,

 

I would like to include something like this under each users Author Username or Rank on the Forum Message Page.

 

I have tried many variations of: 

<component id="users.widget.single-statistic" metric="net_overall_posts"/>
<component id="users.widget.single-statistic" metric="net_kudos_weight_received"/>
<component id="users.widget.single-statistic" metric="net_accepted_solutions"/>

But I can't get it to work and I also get this error

I have also tried setting the correct Text Keys using information from this thread and this thread

I also do not see the User Metrics component within Studio.

 

 

Any help would greatly be appreciated!

9 Replies

  • Hi etchen,

     

    You can use the following the component which displays statistics about the user's activity in the community, but this will work only on the User profile page.

    <@component id="users.widget.my-statistics"/>

    But, to display this on Forum Message Page, you can customize it by using the rest v2 call:

    <#assign getMetrics = rest("2.0", "search?q=" + "SELECT id,value FROM metrics WHERE id IN('net_overall_posts','net_kudos_weight_received','net_accepted_solutions') and user.id='${user.id}'"?url).data.items/>
    
    <#list  getMetrics  as userMetrics>
    <span>${userMetrics.value}</span>
    </#list>

    Let me know if this helps.

     

    Thanks,

    Payal Uppal

  • Inactive User's avatar
    Inactive User
    7 years ago

    Hi Uppal,

     

    Thank you for your reply.

     

    Can you point me in the right direction of where I would apply this?

    <#assign getMetrics = rest("2.0", "search?q=" + "SELECT id,value FROM metrics WHERE id IN('net_overall_posts','net_kudos_weight_received','net_accepted_solutions') and user.id='${user.id}'"?url).data.items/>
    
    <#list  getMetrics  as userMetrics>
    <span>${userMetrics.value}</span>
    </#list>

    Thanks,

  • Payal's avatar
    Payal
    Director
    7 years ago

    Inactive User - You have to add this in custom component, create a new component in studio, add this code and then add this component to the Forum Topic Page. 

    https://prnt.sc/im7uax

     

    Thanks,

    Payal Uppal

  • Inactive User's avatar
    Inactive User
    7 years ago

    Thanks Payal - but I managed to solve this by creating a new custom component using different variables :-)

  • nad_dyra303's avatar
    nad_dyra303
    Guide
    5 years ago

    Inactive User Payal hi

     

    I also try to create custom components for user statistics. but the problem is that, if i clicked another user, the stats from my profile being drag to another user. so how to make sure that we fetch the data for different user?

  • Payal's avatar
    Payal
    Director
    5 years ago

    nad_dyra303  - If you have used a custom component on profile page, then instead of using the "user.id", you need to use "page.context.user.id" context object.

    Please let me know if this works.

    Thanks!

  • Payal i got this error and below is my snippet for the coding. Is there missing something?

     

    FreeMarker template error (HTML_DEBUG mode; use RETHROW in production!)

    The following has evaluated to null or missing:
    ==> page.context.user  [in template "preview" at line 7, column 220]

     



     

     

     

    <div class="profile-likes">
    	<div class="profile-flex"><img src="/html/assets/icon-posts.png" /> <#assign getMetricsPost = rest("2.0", "search?q=" + "SELECT id,value FROM metrics WHERE id IN('net_overall_posts') and page.context.user.id='${page.context.user.id}'"?url).data.items/> <#list  getMetricsPost  as userMetricsPost>
    <span>${userMetricsPost.value}</span> </#list> Posts </div> 
    	

     

     

     

    Regards,
    Nad

  • Payal's avatar
    Payal
    Director
    5 years ago

    nad_dyra303 - I have made update to the following code:

    <div class="profile-likes">
    	<div class="profile-flex"><img src="/html/assets/icon-posts.png" /> <#assign getMetricsPost = rest("2.0", "search?q=" + "SELECT id,value FROM metrics WHERE id IN('net_overall_posts') and user.id='${page.context.user.id}'"?url).data.items/> <#list  getMetricsPost  as userMetricsPost>
    <span>${userMetricsPost.value}</span> </#list> Posts </div> 
  • Payal thank you so much! It Worked. Just need to beautify it now. Just error in the studio but worked when view the profile page


    Regards,
    Nad