是否可以为Application Insights中的现有页面视图数据更改自定义属性的名称?
答案 0 :(得分:1)
您可以在页面查看事件离开浏览器之前用telemetry initializer更改页面查看事件的任何属性:
在您从门户网站获得的初始化代码段后立即添加此代码。
...
window.appInsights = appInsights;
// Add telemetry initializer
appInsights.queue.push(function () {
appInsights.context.addTelemetryInitializer(function (envelope) {
var telemetryItem = envelope.data.baseData;
// To check the telemetry item’s type:
if (envelope.name === Microsoft.ApplicationInsights.Telemetry.PageView.envelopeType) {
// this statement removes url from all page view documents
telemetryItem.url = "URL CENSORED";
}
// To set custom properties:
telemetryItem.properties = telemetryItem.properties || {};
telemetryItem.properties["globalProperty"] = "boo";
// To set custom metrics:
telemetryItem.measurements = telemetryItem.measurements || {};
telemetryItem.measurements["globalMetric"] = 100;
});
});
// end of insertion
appInsights.trackPageView();
此外,您可以在Google Analytics(分析)查询中的查询时间对列进行别名或复制:
pageViews | summarize sum(itemCount) by NameB=tostring(customDimensions.NameA) | ...
pageViews | extend NameB = customDimensions.NameA | ...