Adding Google Analytics to a PWA (Ionic 3)

Hi all, I’m looking to add Google Analytics to a quiz competition PWA (Ionic 3), which has no URL structure. I’m considering following the advice in this article, which recommends using Google Tag Manager:

Seems a bit daft to have to include jQuery though but nevertheless thought I would give it a shot. Am I on the right track here or can anyone recommend a better, cleaner solution for adding GA to a URL-less Ionic web app? Any advice is appreciated.

1 Like

Tag Manager and jQuery definitely sound like overkill.

Just find a way to add a normal Google Analytics JS library to your Ionic app and then call the page events (or however you choose to track your app) manually if the automated tracking doesn’t work (what I expect if your don’t have proper URLs).

Thanks @Sujan12. Is it possible you can recommend a web app compatible JS library that doesn’t require Cordova.

Nope, no experience, sorry.

I use raw Google Analytics at

For each page I override onViewEnter() method and send a pageview message to GA with custom URL.

Works like a charm.


I have a single code base targeting Android, iOS and Web platforms. Is it possible to use the plugin for all three platforms? Also, do you have any code snippet that you could share? It’d really help me if you could gimme spme code to look at.

We also have the same code base for PWA and our native apps.

Not sure if this is the best approach, but as we are not targetting the cordova Browser platform we implemented vanilla Google Analytics in the PWA and used the GA Cordova plugins for the rest.

We now have to figure out a way to add the GA Javascrript code for the PWA build and not for the Cordova build…