question

Letterhead-7589 avatar image
0 Votes"
Letterhead-7589 asked SwathiDhanwada-MSFT commented

Application Insights Click Analytics Auto-collection plugin in Angular

Hello Community,
Does anyone know how to implement the Click Analytics Auto-collection plugin in Angular?

I created a service for App Insights and I'm able to send events when I call logEvent from a component, but the auto-collection plugin does not appear to be doing anything when I click on elements I've assigned the custom html tag data-click- to.

Thank you!

 //TelemetryService.ts
 import { Injectable } from '@angular/core';
 import { ApplicationInsights } from '@microsoft/applicationinsights-web';
 import { ClickAnalyticsPlugin } from '@microsoft/applicationinsights-clickanalytics-js';
 import { environment } from 'src/environments/environment';
    
 @Injectable({ providedIn: 'root' })
 export class TelemetryService {
   appInsights: ApplicationInsights;
   constructor() {
     const clickPluginInstance = new ClickAnalyticsPlugin();
     this.appInsights = new ApplicationInsights({
       config: {
         instrumentationKey: environment.appInsights.instrumentationKey,
         extensions: [clickPluginInstance],
         extensionConfig: {
           [clickPluginInstance.identifier]: clickPluginConfig
         }
       }
     });
     this.appInsights.loadAppInsights();
   }
    
   logEvent(name: string, properties?: { [key: string]: any }) {
     this.appInsights.trackEvent({ name: name}, properties);
   }
 }
     
 // Click Analytics configuration
 const clickPluginConfig = {
   autoCapture: true,
   dataTags: {
     useDefaultContentNameOrId: true,
     customDataPrefix: "data-click-",
   }
 };





azure-monitor
· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi @Letterhead-7589,

Apologies for the delayed response. Are you still facing this issue? Have you tried following the steps in this doc ? Click Analytics Auto-collection plugin for Application Insights JavaScript SDK

Thanks,
Grace




0 Votes 0 ·

@Letterhead-7589 As mentioned in previous comment, have you tried the steps mentioned in the document? Do revert if need further assistance.

0 Votes 0 ·

0 Answers