0

I´m trying to integrate Angulartics in my AngularJS 1.0.7 web app for Google Analytics. When trying to load the main page I get this error:

Uncaught TypeError: undefined is not a functionangulartics.min.js:6 (anonymous function)angular.js:2892 invokeangulartics.min.js:6 (anonymous function)angular.js:2895 invokeangular.js:2744 (anonymous function)angular.js:130 forEachangular.js:2744 createInjectorangular.js:978 resumeBootstrapInternalangular.js:993 bootstrapangular.js:954 angularInitangular.js:14843 (anonymous function)jquery-1.10.2.min.js:4 x.Callbacks.cjquery-1.10.2.min.js:4 x.Callbacks.p.fireWithjquery-1.10.2.min.js:4 x.extend.readyjquery-1.10.2.min.js:4 q

I have added the modules like this:

angular.module('myApp', ['myApp.filters', 'myApp.services', 'myApp.directives', 'myApp.controllers', 'myApp.i18n', 'myApp.properties', 'angularSpinner', 'ngCookies', 'ngSanitize', 'ngProgress', 'angularMoment', 'tmh.dynamicLocale', 'angulartics', 'angulartics.google.analytics'])
  .config(['$routeProvider', '$httpProvider', function($routeProvider, $httpProvider, $routeParams) {...}

I have included the javascript plugins:

<!-- Angulartics -->
    <script src='lib/plugins/angulartics.min.js'></script>
    <script src='lib/plugins/angulartics-ga.min.js'></script>

And finally added the Google tracking snippet code (commenting the last line):

<script>
      (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', 'UA-59702007-1', 'auto');
      // Removed requested by Angulartics (see doc) ga('send', 'pageview');

    </script>
Rober
  • 5,868
  • 17
  • 58
  • 110
  • are you really using angular 1.0.7? This version is almost two years old and not supported anymore by the angular team. The bower.json of angulartics states "angular": ">= 1.1.5", this might be your problem. – Reto Feb 13 '15 at 06:55
  • Yes, I think it´s not so crazy to have a web app with 2 years old. It´s not easy to migrate a big web app from one version to another. I didn´t read anything about minimal version requirements in the Angulartics website, but makes sense according to the error. I hope I don´t have to migrate all my app to integrate Angulartics. – Rober Feb 13 '15 at 07:34
  • Try adding the non-minified version of angulartics, then you will get a clear stack trace. Should be easy to fix, angulartics is not complex. – Reto Feb 13 '15 at 08:31

1 Answers1

0

Finally solved it by using Angularytics instead of Angulartics. I had no integration dependencies issues.

Rober
  • 5,868
  • 17
  • 58
  • 110
  • integration dependencies ? I am so trying to add Angulartics with ionic. Any suggestions : http://stackoverflow.com/questions/28867485/integrating-angulartics-with-ionic-framework ? – Shoebie Mar 05 '15 at 00:03