https://github.com/pocesar/angular-ecommerce-analytics
Google Analytics Ecommerce helper with tracking events
https://github.com/pocesar/angular-ecommerce-analytics
Last synced: 12 months ago
JSON representation
Google Analytics Ecommerce helper with tracking events
- Host: GitHub
- URL: https://github.com/pocesar/angular-ecommerce-analytics
- Owner: pocesar
- License: mit
- Created: 2015-04-14T04:52:29.000Z (about 11 years ago)
- Default Branch: master
- Last Pushed: 2015-08-11T09:38:54.000Z (almost 11 years ago)
- Last Synced: 2025-06-03T11:32:33.214Z (about 1 year ago)
- Language: TypeScript
- Size: 172 KB
- Stars: 4
- Watchers: 4
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# angular-ecommerce-analytics
[Google Analytics Ecommerce](https://developers.google.com/analytics/devguides/collection/analyticsjs/enhanced-ecommerce) helper with tracking events
## Install
```bash
bower install angular-ecommerce-analytics
```
## Usage
#### Service
```js
// 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.
```html
Pay with Debit
```