I am trying to use Angulartics with Ionic Framework. However, nothing is tracking on google analytics. Here is how a set it up.
index.html.slim file
<script src="lib/angulartics/src/angulartics.js">
<script src="lib/angulartics/src/angulartics-ga-cordova.js">
javascript:
(function(i,s,o,g,r,a,m)
{i['GoogleAnalyticsObject']=r;i[r]=i[r]||function() {
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();
a=s.createElement(o),
m=s.getElementsByTagName(o)[0];
a.async=1;
a.src=g;
m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', '#{ENV['GOOGLE_ANALYTICS_ID']', { 'cookieDomain': 'none' });`
Added it to my angular module
angular.module('app', ['angularMoment', 'angulartics', 'angulartics.google.analytics.cordova', 'ngCordova'])`
Adde $analyticsProvider to my config in routes
.config ($analyticsProvider, $stateProvider, $urlRouterProvider) ->
I am not getting any data on my google analytics Dashboard. Can someone please explain how to install Angulartics in my ionic project.
Ionic is a framework for developing hybrid applications that supports mobile and web platforms.
Yes, there are use cases for Ionic, if what you're looking for is a reactive web app - where your web code can be used to quickly produce a mobile version - but - going down that route, using a framework which has performance and availability issues hitting phone hardware means that you're effectively ignoring a lot of ...
Think of Ionic as the front-end UI framework that handles all of the look and feel and UI interactions your app needs in order to be compelling. Kind of like “Bootstrap for Native,” but with support for a broad range of common native mobile components, slick animations, and beautiful design.
Ionic apps are built using the languages of the web: HTML, CSS, and JavaScript. Thus, if you know how to build a basic web app, you already know how to build with Ionic. With Ionic, you can deploy a native iOS or Android app, native desktop app, or web app, all from a single, shared codebase.
Please take a look at the angulartics-ga-cordova script file here: https://github.com/luisfarzati/angulartics/blob/master/src/angulartics-ga-cordova.js
On line 48, it is expecting the GAPlugin.
var analytics = window.plugins && window.plugins.gaPlugin;
You will need to add this script to your main index file. https://github.com/phonegap-build/GAPlugin
Then you can add your google tracking info like this.
myApp.config ($analyticsProvider, googleAnalyticsCordovaProvider) ->
$analyticsProvider.firstPageview(true)
googleAnalyticsCordovaProvider.trackingId = GOOGLE_ANALYTICS_ID
Also, if you are using phonegap build, you will need to add the following line to your config.xml file.
<gap:plugin name="com.adobe.plugins.gaplugin" />
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With