Implementing Google Analytics in Ionic 5 with Capacitor

Hi All,
Tryin to use GoogleAnalytics in PWA

import { Plugins } from '@capacitor/core';
const { GoogleAnalytics } = Plugins;

... 

initializeApp() {
    GoogleAnalytics.startTrackerWithId('G-0000000000')
    .then(() => {
        alert('Google analytics is ready now');
    })
   .catch(e => alert(e));

After this I get the following error :

GoogleAnalytics does not have web implementation.

If I do the Cordova implementation all I got is that cordova_not_available

Tried to register the WebPlugin

import { Plugins } from '@capacitor/core';
import { registerWebPlugin } from '@capacitor/core';
const { GoogleAnalytics } = Plugins;
registerWebPlugin(GoogleAnalytics);

But

ERROR in app.component.ts:159:25 - error TS2345: 
Argument of type '{ [prop: string]: any; }' is not assignable to parameter of type 'WebPlugin'.
Type '{ [prop: string]: any; }' is missing the following properties from type 
'WebPlugin': config, loaded, listeners, windowListeners, and 9 more. 

Ionic info:

Ionic CLI                     : 5.4.16
Ionic Framework               : @ionic/angular 5.3.2
@angular-devkit/build-angular : 0.1001.1
@angular-devkit/schematics    : 8.1.3
@angular/cli                  : 10.1.1
@ionic/angular-toolkit        : 2.3.3

Capacitor CLI   : 1.5.3
@capacitor/core : 1.5.3

Cordova CLI       : 9.0.0 (cordova-lib@9.0.1)
Cordova Platforms : android 8.1.0, browser 6.0.0
Cordova Plugins   : cordova-plugin-ionic-keyboard 2.2.0, cordova-plugin-ionic-webview 4.2.1, (and 12 
other plugins)

cordova-res (update available: 0.15.1) : 0.9.0
native-run (update available: 1.0.0)   : 0.2.9


Android SDK Tools : 26.1.1
NodeJS            : v12.13.1
npm               : 6.12.1
OS                : Windows 10

Anyone could point me in the right direction?

Docs says both Cordova and Capacitor should work in the browser (PWA).
Or do I misunderstand something?

Thanks

3 Likes