angular-ga icon indicating copy to clipboard operation
angular-ga copied to clipboard

Answer common questions about installation and use in readme

Open fotoflo opened this issue 10 years ago • 3 comments

Hi there, I have a bunch of questions:

where does this GA get the site's GA tracking ID?

  • assuming we should put the tag on index.html

how to properly send a pageview?

  • like this? ga('send', 'pageview', {title: 'Sign up for TexTurner!', page: "/#/core/signup"});

how to properly send an event?

  • like this? ga('send', { 'hitType': 'event', // Required. 'eventCategory': 'button', // Required. 'eventAction': 'click', // Required. 'eventLabel': 'nav buttons', 'eventValue': 4 });

fotoflo avatar Jul 16 '15 04:07 fotoflo

Also, does it support ecommerce sending? A quick look at the code seems to suggest it only works if the arguments are an array, so the below wont work, cause it is never sent.

    ga('ecommerce:addTransaction', {
      'id': Date.now(),                     // Transaction ID. Required.
      'revenue': $scope.addAmount,               // Grand Total.
    });
    ga('ecommerce:send');

fotoflo avatar Jul 16 '15 05:07 fotoflo

I've decided the best way for me to implement pageview tracking is to stick them in a resolve inside my router (that way all the page view tracking is in one place, and can be edited easily.

fotoflo avatar Jul 16 '15 05:07 fotoflo

It works exactly as per analytics documentation. You set the id in index.html and use the ga function just as you would use window.ga (all passed arguments are passed intact).

panrafal avatar Jul 29 '15 07:07 panrafal