angular-ga
angular-ga copied to clipboard
Answer common questions about installation and use in readme
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 });
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');
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.
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).