Using Google Analytics in an Ionic App without a plugin

Using Google Analytics in an Ionic App without a plugin

Originally we were using the popular Cordova Google Analytics Plugin. There are advantages to using the plugin, as it interfaces with the native GA SDKs and provides features such as request batching and offline tracking, but we ran into regular issues and a consistently broken Android build. For our simple event tracking and pageview use cases we decided to go with a more straightforward approach and use the analytics.js file directly. ​

The tracking worked fine when serving Ionic in the browser but did not work on any device, even though the hitCallback was being successfully invoked. (It turns out the hitCallback gets invoked on any response from the server so do not rely on it as an indicator of a successful ‘hit’.) ​

The problem turned out to be that GA was checking to see whether the current browser protocol was http:// or https:// so it could match it. In an Ionic app the protocol is actually file:// so this needed to be circumvented. ​

Click here to see the full article.

Very Good. I would know how to redeem the past Referrer for Google Play Thank You :)

Like
Reply

To view or add a comment, sign in

More articles by Chris Lloyd

  • Filling the gap with low-code apps

    By Chris Lloyd, CTO for StoryShare by 27partners When enterprises look for technological solutions they consider two…

    1 Comment
  • The role of the CTO

    Keeping one foot in today and one foot in tomorrow. The role of a Chief Technology Officer (CTO) is not something that…

    1 Comment
  • Virtual Reality and Travel

    Without a doubt, everyone’s favourite activity during the winter months is reminiscing about the summer holidays. While…

  • A day in the life of a developer

    Software developers are the behind-the-scenes workforce that have built the modern age. They are the creators of all…

    1 Comment
  • Cloud based services

    Cloud based services can run a function of a company’s infrastructure; anything from storage, management and security…

  • VR lets us fight fires without the heat

    How to experience dangerous and remote sites from the safety of your own office In the last 10 years the number of…

  • Top 10 tips for enterprise video

    With the use of video in the workplace growing rapidly, live and on-demand streaming across multiple platforms and…

  • Why your business needs an enterprise video strategy

    Video production involves a myriad of product and service providers all solving a particular part of the puzzle, yet…

    4 Comments

Explore content categories