cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Manc_Gurl
Advocate II
Advocate II

Count the number of times clicked

I've created an app that uses a SharePoint list as the datasource.  My app contains a gallery which has a "link" column (html text) containing a hyperlink to either a document or website.  I'm trying to think of a way to count the number of times a "link" in a gallery item is clicked.  I'm not sure if this is possible?  I though perhaps I could have a column called "Count" in my SP list and then in the On Select property of my link field in the app I would be able to patch the value 1 to the count column in the list but this doesn't seem to be working. 

 

The client has asked if we can establish what items are popular or regularly clicked on in the app.  I looked at the app analytics page but it doesn't seem to store this kind of information so I need to figure out a way to do it inside the app.  My app is just a fancy front end search and filter tool, currently doesn't write anything back to SharePoint.

 

Is this even possible? TIA

1 ACCEPTED SOLUTION

Accepted Solutions
mdevaney
Super User III
Super User III

@Manc_Gurl 
You have the right idea on how to accomplish this.  Does each document or website have a hyperlink or a unique title you could use to store the count of clicks?

 

Create a table like this called CountOfClicks

 

URL TotalClicks
www.google.ca 23
www.arstechnica.com 4
www.reddit.com 34

 

Assuming the gallery holds the URL you could put this code in the OnSelect property of your button to track clicks

Set(currentRecord, LookUp(CountOfClicks, URL = ThisItem.Hyperlink));

If(
    IsBlank(currentRecord),
    //create a new record when URL is new and start at 1 click
    Patch(CountOfClicks, Defaults(), {URL = ThisItem.Hyperlink, Clicks: 1}),
    //add clicks to a record when URL already exists
    Patch(CountOfClicks, currentRecord, {Clicks: currentRecord.Clicks + 1})
)

 

 

---
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

View solution in original post

2 REPLIES 2
mdevaney
Super User III
Super User III

@Manc_Gurl 
You have the right idea on how to accomplish this.  Does each document or website have a hyperlink or a unique title you could use to store the count of clicks?

 

Create a table like this called CountOfClicks

 

URL TotalClicks
www.google.ca 23
www.arstechnica.com 4
www.reddit.com 34

 

Assuming the gallery holds the URL you could put this code in the OnSelect property of your button to track clicks

Set(currentRecord, LookUp(CountOfClicks, URL = ThisItem.Hyperlink));

If(
    IsBlank(currentRecord),
    //create a new record when URL is new and start at 1 click
    Patch(CountOfClicks, Defaults(), {URL = ThisItem.Hyperlink, Clicks: 1}),
    //add clicks to a record when URL already exists
    Patch(CountOfClicks, currentRecord, {Clicks: currentRecord.Clicks + 1})
)

 

 

---
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

View solution in original post

Thank you @mdevaney  this helped me immensely!

Helpful resources

Announcements
PA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

Power Query PA Forum 768x460.png

Check it out!

Did you know that you can visit the Power Query Forum in Power BI and now Power Apps

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

PowerPlatform 768x460.png

Microsoft Learn

Check out our new Discover Your Career Path blog post series and get all the details.

Users online (2,083)