Adding Telemetry to My Web App with Azure Application Insights
Before I point my domain abdulkoomson.com to my current live site, which is hosted at abdulkoomson.azurewebsites.net (on Azure’s free tier), I want to understand how users interact with my site.
That means adding telemetry—specifically, tracking how visitors navigate, what pages they visit, and how long they stay. To do that, I integrated Azure Monitor Application Insights using the JavaScript SDK for real user monitoring.
🔍 What I Want to Measure
- Page views
- User navigation paths
- Session duration and bounce rates
- Application availability and response times
While Azure Monitor provides full-stack observability, I’m primarily focused right now on the frontend telemetry—especially page views and user engagement before I officially launch with my domain.
🛠️ Implementation: JavaScript SDK
To enable real user monitoring, I added the Azure Application Insights JavaScript SDK to my site. This lets me capture telemetry directly from the client side without needing any backend dependencies.
Here's the basic code snippet I added to my main HTML file:
<script type="text/javascript">
var appInsights = window.appInsights || function (config) {
function r(config) {
t[config] = function () {
var i = arguments;
t.queue.push(function () {
t[config].apply(t, i);
});
};
}
var t = { config: config }, u = document, e = window, o = "script", s = u.createElement(o), i, f;
s.src = config.url || "https://az416426.vo.msecnd.net/scripts/a/ai.0.js";
u.getElementsByTagName(o)[0].parentNode.appendChild(s);
t.cookie = u.cookie;
t.queue = [];
i = ["trackPageView", "trackEvent", "trackException", "trackMetric", "trackDependencyData", "trackTrace", "setAuthenticatedUserContext", "clearAuthenticatedUserContext", "flush"];
for (f = 0; f < i.length; f++) r(i[f]);
return t;
}({
instrumentationKey: "YOUR_INSTRUMENTATION_KEY"
});
window.appInsights = appInsights;
appInsights.trackPageView();
</script>
You can generate this snippet directly from Azure Portal when setting up Application Insights for your web app.
📊 Benefits of App Insights
Here’s what I like about Application Insights so far:
- Works with static and dynamic sites (including Flask)
- Tracks page views out of the box
- Collects telemetry like response time, failed requests, and JS errors
- Easy integration with Azure Dashboards and Power BI
- Customizable events for advanced use cases
🔒 Privacy & Lightweight Loading
I made sure telemetry collection complies with basic privacy considerations—nothing invasive or PII-based. You can control what data is captured and anonymize IPs if needed.
📈 Next Steps
- Review metrics on user engagement weekly
- Map user flows to see how people navigate between blog posts
- Use data to improve layout, navigation, and content organization
- Upgrade my hosting plan and connect my domain: abdulkoomson.com
💬 Final Thoughts
Telemetry is like a feedback loop for your website—it tells you what’s working, what’s not, and what users actually care about. With Azure Application Insights in place, I now have a lens into how people move through my content before I make anything permanent.
Got tips on improving user analytics or want help setting up Application Insights? Let’s chat.