Application Insights is a powerful feature in Azure Monitor that allows you to collect detailed telemetry data from your Power Pages site. It helps track portal usage, performance, errors, page views, user sessions, and custom events. By integrating Application Insights with Power Pages, you gain rich observability into how your portal behaves and how users interact with it.
Table of Contents
- What is Application Insights?
- Benefits of Using Application Insights in Power Pages
- Prerequisites
- Step-by-Step Integration
- Viewing Telemetry Data
- Common Telemetry Scenarios
- Custom Events and Metrics
- Troubleshooting and Best Practices
- Summary
- Tags
1. What is Application Insights?
Application Insights (App Insights) is a service within Azure Monitor that provides powerful telemetry and logging capabilities. It can automatically track:
- Page views
- Performance metrics
- Failures and exceptions
- Custom user events
- Backend dependencies (like APIs)
2. Benefits of Using App Insights in Power Pages
- Real-time monitoring of how users interact with the portal
- Detect issues like performance slowdowns, failed form submissions, or broken links
- Track user session paths
- Analyze usage patterns and popular content
- Measure load times and API response delays
- Set up alerts for specific behaviors
3. Prerequisites
To use Application Insights with Power Pages, you need:
- A Power Pages site (formerly Power Apps Portal)
- An active Azure subscription
- Application Insights resource created in Azure
- Admin access to the Power Platform and Azure
4. Step-by-Step Integration
Step 1: Create Application Insights Resource
- Go to Azure Portal
- Click Create a resource → Application Insights
- Fill in:
- Name:
MyPowerPagesTelemetry
- Application Type: General
- Resource Group: Choose or create one
- Name:
- Click Review + Create and then Create
Once created, note down the Instrumentation Key or Connection String
Step 2: Add App Insights to Power Pages
- Go to Power Pages Admin Center
- Select your site → Go to Site Settings
- Create a new Site Setting:
- Name:
ApplicationInsights.InstrumentationKey
- Type:
String
- Value: Paste your Instrumentation Key here
- Name:
ApplicationInsights.ConnectionString
- Value: Your Connection String (preferred method)
- Name:
- Save the changes and restart the portal if needed
5. Viewing Telemetry Data
After a few minutes, data starts flowing into your Application Insights resource.
Navigate to:
Azure Portal → Application Insights → Choose your resource
Key sections:
- Live Metrics: Real-time data of requests, users, and failures
- Users: Track user sessions, countries, and behaviors
- Sessions: See how long users stay and what pages they visit
- Failures: Exceptions, dependency errors, and failed AJAX calls
- Performance: Page load times, server response delays
- Events: Page views, custom events, and button clicks
- Availability: Set up tests to monitor uptime
6. Common Telemetry Scenarios
Scenario | Feature to Use |
---|---|
High load times | Performance → Page Load Time |
API errors | Failures → Exceptions |
User paths | Users → Session Timeline |
Portal not loading | Live Metrics / Failures |
Which pages are most popular? | Events → PageViews |
7. Tracking Custom Events and Metrics
You can extend telemetry by adding custom logging to your portal using JavaScript.
Example: Track Button Clicks
if (window.appInsights) {
document.getElementById("submit-btn").addEventListener("click", function() {
appInsights.trackEvent({ name: "SubmitButtonClicked" });
});
}
Other APIs:
trackException()
trackTrace()
trackMetric()
trackPageView()
These help you build advanced analytics dashboards using Kusto Query Language (KQL).
8. Troubleshooting and Best Practices
Data Not Appearing?
- Check if the instrumentation key is correct
- Ensure portal is live and traffic is hitting it
- Use browser DevTools to inspect if
ai.js
is loaded - Use Network tab to see telemetry events being sent
Best Practices
- Avoid sending sensitive data
- Use sampling for high-traffic portals
- Set up alerts on:
- Load time > X seconds
- Failures per minute
- User drop-off rate