mgonto / angularytics

The solution to tracking page views and events in a SPA with AngularJS
MIT License
630 stars 70 forks source link

can this use with local html at webview? how? #7

Closed atian25 closed 11 years ago

mgonto commented 11 years ago

Hey,

Yes you should be able to. You should ask for Internet permission though (If using Android), and then jsut include the Angularytics JS before your app, add the module of the dependency, include Analytics Script in your HTML and that's it. Just like any regular webpage!

Thanks for suing it!

atian25 commented 11 years ago

thanks.

I'm new to google analytics. Is this right? I can't see any output at console.

    <script src="http://www.google-analytics.com/analytics.js"></script>
    <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', 'XXXXXXX', 'XXXXXXX');
      ga('send', 'pageview');
    </script>
    <script src="../../components/angularytics/dist/angularytics.js"></script>
app.config(['AngularyticsProvider',
    function(AngularyticsProvider){
      AngularyticsProvider.setEventHandlers(['Console', 'Google']);
    }
]).run(['$rootScope', 'promiseTracker','Angularytics', function($rootScope, promiseTracker, Angularytics){
    $rootScope.loader = promiseTracker('loader');
    Angularytics.init();
}])
mgonto commented 11 years ago

You should use GoogleUniversal (as you're using ga not _gaq).

Also, you should set the XXX to the Analytics value of your account.