Total Page hit count in PowerApps.

Introduction

The total page view count is frequently displayed on numerous websites. In one of my use cases, I needed to display the total number of times a person has visited the page. We will also look at the number of views requests with details, which indicates the number of entries created for any given request.

Scenario

In the article, a few scenarios will be covered.

Objective

This requirement's goal is extremely difficult because it frequently displays the overall number of views on the page as well as the number of users who have left comments on any given article. We'll continue to patch the most recent count to a list row and display it on the power apps.

Step 1. The list structure would look like below.

A list structure might be created based on our requirements. I've made three distinct lists for this sample, and the data is displayed along with the list structure.

structure of the List

Structure of the List

Article list content

Article list content

PostViewsOnArticle list structure

PostViewsOnArticle

PostViewsOnArticle Content

Article Content

The third list will save data from powerapps and the list structure looks like below.

Powerapps

Step 2. Design screen and form as per requirement.

The below screenshot shows all the articles that are entered, on clicking on articles, we can see the details of the article and all the views that we got on that article. To show all articles, I have taken gallery control.

Design screen

Below is the display form which shows the variable View value. Variable View value shows gallery-selected item details.

Variable View

Step 3. Save Logged in User in a Global variable.

We keep logged-in user details in a global variable for performance improvement. Otherwise User(). The email could be used directly wherever required.

Save Logged

Step 4. Add a list of DataSource from SharePoint.

Add PageViewCountItemWise List from SharePoint as DataSource.

So that the patch function can use this data source to store the views and show them back on the PowerApp.

DataSource

Step 5. Patch the count on the OnVisible Property of the page. Show total views on a page on powerapps or view on page load.

We will patch the OnVisible property. If it's a first-time entry then the patch function will create a new record and update the existing one.

Note. The onVisible property only runs after the screen is loaded. We have to manually load the screen for the first time. Go to any other screen and come back to this screen to run the OnVisible property.

OnVisible property

Step 6. Must run the App’s Run OnStart.

We must run the below property in case we are not seeing the values.

Run OnStart

Step 7. Add a Label and show it on the screen.

Add a label and show the count on that label. To look better we can have an icon with attractive visuals.

Container we use to enhance the UI by selecting.

Add a label

Icon 2

Screens

Step 8. Add a Label and show it on the screen.

Add a label and show the count on that label. To look better we can have an icon with attractive visuals. We container as shown above to make the glossy look.

Glossy look

Here I am extracting the row count that is submitted for that particular article from the list.

Extracting the row

Conclusion

We showed in the preceding example how we could depict all of the views, opinions, or ideas that were offered for an article. We also showed how to display the number of page hits.


Similar Articles