0

We have a SharePoint online modern page which contains, those main Web Parts:-

  1. Quick links

  2. News web part

now we want to capture the users clicks and store them inside a SharePoint online list to show the statistics inside Power Apps or Power BI. so if UserA clicks on quick link named "Our Website" >> to capture this info inside a SharePoint custom list:-

Title---> CreatedBy

Our Website---> UserA

Our Website---> UserB

so how we can build such a feature? and can we benefit from the Graph API to get those info and show them inside Power Apps or Power BI instead of building this from scratch ?

6
  • 1
    SharePoint audit logs? Commented Sep 12, 2022 at 14:45
  • @Christoffer but how we can build a sharepoint list with those results? also i am using sharepoint online
    – John John
    Commented Sep 12, 2022 at 16:30
  • 1
    how about creating spfx and embed that in that page. That SPFX will not have any UI and on load it will save the user info in the list, before saving in the list check if user already exists for that date.
    – Saira
    Commented Sep 12, 2022 at 22:38
  • @Saira and how i can capture which link/s the users click on inside the SPFX?
    – John John
    Commented Sep 12, 2022 at 22:49
  • 1
    You can capture that link with a link event in SPFX. I will try to create an example for you
    – Saira
    Commented Sep 12, 2022 at 23:02

1 Answer 1

1

You can try adding SPFX in that page. As an example I have called a function and capturing the quick links. Please note that I am using Quiklinks of compact layout option. enter image description here

In SPFX , call the custom function and in that function capture the a href of the quick links

  private TestFunction(): void {
    $(document).off().on('click', 'div[class=ms-List-cell]', function() {
        var qLink = $(this).find('a').attr('href');
        console.log(`qLink `); 
        console.log(qLink); Here check qLinks if that is of your company then add in SharePoint with current user.
  });

}

Hope this will give you some direction

7
  • thanks for the code and info,, but in SharePoint in general and SharePoint online specifically those markups can be changed, am i correct?
    – John John
    Commented Sep 13, 2022 at 6:39
  • 1
    I have tested in different browsers, as long as you are referring the class names which are generic , you are good to go
    – Saira
    Commented Sep 13, 2022 at 6:48
  • 1
    Yes it may… there is no other way to capture what you want . One way is you May update your SPFX and save the class names in separate class so you can update in one place only. And I don’t think Microsoft will do frequent updates to their class
    – Saira
    Commented Sep 13, 2022 at 7:31
  • 1
    Yes, Once you captured the markup and you have added the logic to capture what link you want to work on , then you can can use Rest Api or use Pnp to save in the desired SP List and using spfx you already would be having the user who is doing the click. In your logic do check if entry is already there within ( say half hr ) time space then dont add.
    – Saira
    Commented Sep 13, 2022 at 22:51
  • 1
    Please mark it as answered if it has given you the direction to your question.
    – Saira
    Commented Sep 14, 2022 at 5:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.