Below are the components used in this document:
- Power Apps
- Azure Application Insight
Introduction
Many times we get a requirement where a user has to track user activities like how many users visited the screen or which user clicked on a particular button on the Power App Form. This can be made possible using Azure Application Insights. You can check the link on how to create an Azure Application Service by clicking on MS Doc
link. Below is the step by step description to achieve the same.
Get Application Insight Instrumentation Key
- Open Azure Portal and browse to your Application Insight
- Copy the Instrumentation Key mentioned on the screen.
Add Azure Application Insight to Power Apps
- Open your Power Apps form and click on the App on the left menu bar
- Paste the Instrumentation Key copied from the Azure portal in the below highlighted section
- Now your Power App form is integrated with Azure Application Insight, but how to write the information to insight? That can be done using Trace(). For example: log information of the current user to Insights.
Here in the above example, I am tracing user login, the type of trace is just simple information (since it is not a warning or error to be logged) and lastly I am sending some custom details like User Name, UserEmail and Screen Name to be logged in Insights.
- Similarly we can log the button clicks as well to Insights.
Here in the above example I am logging User Name, User Email, Screen, Event, and some other metadata from the form.
Now play the power app form and you can browse to the screens and click on the button where you are tracing the information to Insight. Then you can browse to Azure Portal to view the Information logged in the Insight you created.
That is it. I hope you have learned something new from this article and will utilize this in your work.