angular-ecommerce-analytics

Google Analytics Ecommerce helper with tracking events

Angular Core Dependency: >=1.3 <2

Added by: Sam Deering

GitHub

Repository

pocesar/angular-ecommerce-analytics

Stats

Stars: 4

Watchers: 4

Forks: 1

Author

Paulo Cesar
Paulo Cesar

Module Description

angular-ecommerce-analytics

Google Analytics Ecommerce helper with tracking events

Install

bower install angular-ecommerce-analytics

Usage

Service

// add your GA.js code before this script
angular.module('App', ['Analytics']).run(['$analytics', function($analytics){
    // send by code
    $analytics.setAction(4 /* CHECKOUT */, {
        'step': 2
    }).event({
        eventAction: 'checkout',
        eventCategory: 'plans',
        eventLabel: 'do-checkout-button'
    });
    
    $analytics.addProduct({
        id: '1',
        name: 'product',
        price: 100
    });
    $analytics.setAction(2 /* ADD */);
    $analytics.setAction(3 /* REMOVE */);
    
    $analytics.event({
        eventCategory: 'button',
        eventAction: 'action',
        eventLabel: 'label',
        eventValue: 'value'
    });
    
    try {
        lol++;    
    } catch (e) {
      $analytics.exception({
        exDescription: 'error: ' + e
      });
    }
    
    $analytics.pageView({
        // page: '/randomurl/1'
    });
    $analytics.social({
        socialNetwork: 'facebook',
        socialAction: 'like',
        socialTarget: url
    });
}]);

Directive

  • analytics Support multiple events, either separated by space or by commas
  • analytics-if Conditional to trigger the sending of the event, optional
  • analytics-category Category of the event
  • analytics-label How it will show in the analytics panel
  • analytics-value The value assigned to the event

Every attribute are evaluated for expressions, so literal strings must be set as 'some string'

The same events (click, mouseover, mouseenter, etc) still fires, since the directive won't do anything to the event, and just send tracking data.

<a 
   analytics="click,mouseover,focus" 
   analytics-if="ctrl.isCheckingOut()" 
   analytics-category="'pay'" 
   analytics-label="'debit'" 
   target="_blank" 
   class="btn btn-primary btn-pagamento" 
   ng-href="{{url}}"
   >Pay with Debit</a>

Module stats last updated: 2016-10-29 03:17:11

Disclaimer: Some data on this page may have been gathered from the authors GitHub respository. If you see any mistakes or outdated information please let us know. Thanks!